answersLogoWhite

0

📱

C Programming

Questions related to the C Computer Programming Language. This ranges all the way from K&R to the most recent ANSI incarnations. C has become one of the most popular languages today, and has been used to write all sorts of things for nearly all of the modern operating systems and applications. It it a good compromise between speed, power, and complexity.

9,649 Questions

How do you get principal varivation from iterative deepening search?

You will get principal variation from iterative deepening search using sequential moves within the framework. It is important to note that this may slow down the search due to space requirements.Ê

Hello world program?

A "Hello world" program is usually the very first program you write when learning a new programming language, it simply prints out the text "Hello World". Below are a few examples:

PHP:

echo "Hello World";

_____________________________________

JavaScript:

document.write("Hello World");

_____________________________________ Visual Basic:

Module Hello

Sub Main()

MsgBox("Hello, World!") ' Display message on computer screen.

End Sub

End Module

What makes a Daewoo 2000 Nubira shift suddenly to the right when accelerating?

I had the same problem. This is the problem. The bushings on the lower right control arm are worn out. These are the GM (remember GM bought Daewoo) part numbers, 96308002 and 96492383. They run about $8.00 a piece. Unless you have hit something very, very hard, your control arms should be fine. A local garage/dealer can put press out the old ones and press the new ones in. That fixed the problem with mine.

AnswerMy opinion on this is that it could be the Throttle Position Sensor also called the TPS. I know this because my car did the same thing and we are having to replace this part. Good Luck! AnswerIt is a front wheel drive car, Yes?

Under acceleration, one front tire is getting less grip on the roadway than the other tire is getting, and that is called "torque steer" This is quite normal, and the solution is to back off the gas pedal a bit.

The car is pulling to the right because that right side tire is getting a better grip than the left one is. Just be a little less aggressive on the gas pedal, OK?

AnswerI seriously suggest checking the lower control arms AnswerTyre wear tends to affect this also, mine pulls left under decelration when the tyres are getting down. AnswerCheck right side lower control arm. If accelerate, pulls to right; if deccelerate (not breaking), pulls to left. Install new control arm ASAP! It is not a joke! Same for left side,but the pullings are reversed.

You are SO CORRECT! The right lower control arm had a bad bushing in the rear. Thank you very much.

Be aware!! Replace both sides or you will be back to square one before you know it.. (From experience!)

How do you solve josephus problem using circular linked list?

The Josephus problem is a problem to locate the place for the last survivour. It shows the power of the circular linked list over the singly linked lists.

Write a program in c language that accepts 5 integers as input and sorts them in ascending order using quick sort?

#include <stdio.h>

#include <conio.h>

//Sorting an array with a single FOR loop. No complex coding and testing with multiple array sizes.

int main()

{ clrscr();

int xlist[5]={5,3,4,1,2};

int i,temp;

for (i=0;i<4;)

{

if (xlist[i]<xlist[i+1])

i++;

else

{ temp=xlist[i];

xlist[i]=xlist[i+1];

xlist[i+1]=temp;

i=0;

}

}

for (i=0;i<5;i++)

{ printf("%d ",xlist[i]); }

getch();

return 0;

}

What is the syntax for removing the characters from a string?

There is no need to remove any characters, simply overwrite the first character with a null terminator.

Example:

#include<stdio.h>

void clear_string (char* pstr) {

if (pstr!=0) pstr[0]='\0';

}

int main (void) {

char str[] = "Hello world!";

printf ("\n%s", str); // prints Hello world! on a new line clear_string (str);

printf ("\n%s", str); // prints an empty string

return 0;

}

Note that the character array, str, will effectively contain the character sequence "\0llo World!\0", however the first null-terminator marks the end of the string, so the rest is simply ignored. There is no point in shrinking an array (even a string) unless you absolutely have to, but even then you can only do that with strings allocated on the heap, like so:

#include<stdio.h>

void clear_heap_string (char** ppstr) {

if (ppstr==0 *ppstr==0) return;

char* pstr = realloc (*ppstr, 1 * sizeof(char));

if (pstr==0) return;

pstr[0] = '\0';

*ppstr = pstr;

}

int main (void) {

char* pstr = malloc (13 * sizeof(char));

*pstr = "Hello world!";

printf ("\n%s", pstr); // prints Hello world! on a new line clear_heap_string (&pstr);

printf ("\n%s", pstr); // prints an empty string

free (pstr);

return 0;

}

Note that if the reallocation fails, pstr will still be pointing at the Hello world! string. For that reason it is simpler to just overwrite the first character with a null-terminator, which is always guaranteed to succeed.

What is the function and purpose of cinema?

I've written a Blog about the same topic in relation to some events in my country: http://srijanfoundation.wordpress.com/2007/11/02/chak-de-india-the-non-message/.

Love,

Rahul Dewan

--

http://srijanfoundation.wordpress.com/

http://srijantech.wordpress.com/

http://www.srijan.in

What is a return statement used for?

It means end the function. Functions automatically end when execution reaches the end of the function, but you can return from a function at any point within the function with a return statement.

If the function returns a value to its caller, you must provide a reachable return statement along with the value you wish to return.

Whose variables are also known as global variables?

The variables which are declared outside the main() function is known as global variables and they can be used anywhere in the program.

And,

the variables which used declare inside the main() function is known as local variables and they can be used inside the main() function only.

Example:

#include<stdio.h>

#include<conio.h>

int x,y; // global variables

void main()

{

int a,b; // Local variables

------------

----------------------

---------------------

getch();

}

How do you reference a array from one function to another?

number = myfirstfunction (text, freq); // The first function, where "text" is a string, // and "freq" is the array that is filled with data mysecondfunction (number, freq); // The 2:nd function where the value from the previous // function is being used, and the array "freq" is // bring printed.

What are Short circuit operators in c language?

&& and are short circuit operator in C.

It means that expressions chained with these operators are only evaluated until the result is unambiguously determined. For example, the expression a && b is guaranteed to be false if a is false. In this case, the term b is not evaluated, and any possible side-effects of b will not occur. The logical OR () is implemented in a similar fashion: c d is guaranteed to be true of c evaluates to true, and d is not being evaluated in this case.

The ternary ? operator is not a short circuit operator (this was listed as a short-circuit operator in a previous revision of this answer). An expression that uses the ternary operator, for example e = f ? g : h is nothing but an alternative form of an if-else construct. The terms f, g and h may each contain short-circuit operators and be evaluated in the manner discussed above, but the ternary operator itself has no short-circuit characteristic.

Is 3.121 smaller than 3.12?

No, 3.121 is greater than 3.12 by 0.001.

Is macro a recursive function?

If you're asking if the c preprocessor supports recursive macros, the answer is no. The preprocessor is single-pass and since the "function" must be defined before it can be referenced, it can not be recursive.

Give an example of how getchar function is used in C program.?

The getchar() function is used to read a single character from standard input (stdin) and increment the associated file pointer to point to the next character. The return value is an integer which must be cast to a character.

An example demonstrating its usage is shown below.

#include <stdio.h>

int main()

{

char buffer[81];

int i, ch;

for(i=0; (i<80) && ((ch = getchar()) != EOF) && (ch!='\n'); ++i)

{

buffer[i] = (char) ch; // cast input to a character

}

buffer[i] = '\0'; // add null-terminator.

printf( "You entered: %s\n", buffer);

}

Describe about storage allocation and scope of global extern static local and register variables?

Global Varible:

The variable which is declared as "Global" one : having the preveleges to use and access that variable in any class and object( means any where in the program) just like PUBLIC keyword in OOPS concepts.

Static Variable :

If we declare a variable as Static , then it wont have the permission to access that variable through out the program and u have to use it inside the class or object which u declared itself.

All the Best

Annapurna