Professional Documents
Culture Documents
QUESTION 1
Use the variables initially assigned to the variables for each expression to determine the
value of each the following expressions:
(8*i-2*j+21)%(2*s-c) 0
+j - ++y/-k; 23????
c = = s; 0
('x'-'s')/(j=x=5) 0
What will be output of the following printf statements for i = 91, x = 987.4321, id=204001
QUESTION 2
What will the value of i and j be after it is executed
j=5;
for (i=0; i<5;i++)
{
j++;
++i;
}
a) i= 11 j=5 b) i=6 j=5 c) i=5 j=8 d) i=5 j=6 e) i=6 j=8
if(j= =1)
j++; i++; ++j;
printf("%d %d", j,i);
a) 3 2 b) 5 2 c) 4 2 d) 3 1 e) 4 1
QUESTION 3
2. #define PI 3.14
T
#include <stdio.h>
3. for( ; ; ); T
4. switch (num)
{
case 1;
printf (“num is 1”);
case 2; F
printf (“num is 2”);
?? default;
printf (“num is neither 1 nor 2”); }
QUESTION 4
a) b)
#include<stdio.h> #include<stdio.h>
main() main()
{ {
int i,j; int i,j;
i=1; i=1;
j=2;
do {
while(j<10) j = 1;
{ while(j <= 10)
if(i%3==0) {
j*=2; printf(" %3d",i*j);
++j; j++;
} }
++j; printf("\n");
printf("\n j=%d",--j); i++;
} }
while(i >= 10);
}
j=10 1 2 3 4 5 6 7 8 9 10
d)
#include<stdio.h>
main()
c) {
int i,j,k,x=0;
#include<stdio.h>
main() for (i=0, j = 6; j != i; i++, j--) {
{ switch(i) {
int j,i=2,k=99; case 1: ++i;
printf("\n x1=%d",i);
for(j=1;j<3;++j); break;
{ case 2: i++;
i++;k++;++i,j++; printf("\n x2=%d",i);
printf("\n k=%d",k); break;
printf("\n i=%d",i); case 3: --i;
} printf("\n x3=%d",i);
} break;
case 4: i--;
k=100 printf("\n x4=%d",i);
i=4 break;
default: x=i+j+k;
printf("\n other ");
}
printf("\n i=%d",i);
} other
} i=0
x1=2
i=2
x3=2
i=2