Saturday, November 29, 2008

Predict the counter value

x = 3, counter = 0;
while ((x-1))
{
++counter;
x--;
}

Choice a: 0
Choice b: 1
Choice c: 2
Choice d: 3
Choice e: 4


Predict the output of following programme

void myFunc (int x)
{
if (x > 0)
myFunc(--x);
printf("%d, ", x);
}
int main()
{
myFunc(5);
return 0;
}

Choice a: 1, 2, 3, 4, 5, 5,
Choice b: 4, 3, 2, 1, 0, 0,
Choice c: 5, 4, 3, 2, 1, 0,
Choice d: 0, 0, 1, 2, 3, 4,
Choice e: 0, 1, 2, 3, 4, 5,

Friday, November 28, 2008

Point out the error if any

main() {
int i=1;
while()
{ printf("%d",i++);
if(i>10) break; }
}

a. The condtion in the while loop is must
b. There should be atleast a semicolon in the while()
c. The while loop should be replaced by the for loop
d. No Error

Tuesday, November 18, 2008

What is the output of following programme ?

main() {
int i, x=10, y=100%90;
for(i=1;i<=10;i++) if(x!=y) printf("x=%d y=%d", x,y); } a. The printf() function is called 10 times b. The program will produce the output x=10 y=10 c. The program will not produce any output d. The printf() function is called infinite times

Tuesday, November 11, 2008

You want to declare a pointer to an array of 20 elements containing double values.

Which one of the following statements do you use to declare a pointer to an array of 20 elements containing double values?

Choice a : push(double *array, [20]);
Choice b : double **array[20];
Choice c : double (*array)[20];
Choice d : void pointer = *array[20];
Choice e : double array = *array[20];

Monday, November 10, 2008

You make a change to a C program and run the binary. When the binary is run, it produces the same results as before the change.

It seems like the change has not been honored.
Given the scenario described above, how do you fix the problem?

Choice a: Recompile the program.
Choice b: Clear the program cache and run the binary again.
Choice c: Run ./configure to reconfigure the program.
Choice d: Restart the resident set and run the program again.
Choice e: Touch the Makefile.

Sunday, November 2, 2008

What is the output of following programme ?

main() {
int x=10, y=20;
if(!!!!x||2&&x)
printf("x=%d", x);
else
printf("y=%d",y);
}

a. Y=20
b. X=10
c. X=-10
d. X=0
e. Error