Monday, December 1, 2008

According to the Standard C specification, what are the respective minimum ranges (in bytes) of the following three data types: short, int, long?

Choice a: 1, 2, 2
Choice b: 2, 4, 8
Choice c: 2, 2, 4
Choice d: 2, 4, 4
Choice e: 1, 2, 8

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