Sunday, June 20, 2010

Fresh Graduate IT position question

Here is the answer (^_^):


/* C code */
#include
int main() {
int x = 10; int y = 35;
// x = x * y;
y/=x;
printf("The current value of x is: %i\n", y);
return 0;

}



/* C code */
#include
int main() {
int m=10; int n=5;
int x,y,z;
x=(--m == n++)?--m:++n;
y=m++;
z=n;
printf("The current value of x,y,z is: %i %i %i\n", x,y,z);
return 0;

}


/* C code */
#include
int main() {
int a=1;
int b=10;
do{
b-=a;
a++;
}while(b--<0);
printf("The current value of a,b is: %i %i \n", a,b);


return 0;

}


#include
int main() {
int y,x;
for(y=1, x=1; y<=50; y++)
{if(x>=10) break;
if(x%2==1)
{x+=5;
continue;
}
x-=3;
}
printf("The current value of x,y is: %i %i \n", x,y);

return 0;

}


#include
int main() {
int i,y,x,z;
for(i=0;i<=5;i++) {printf("%d",i);}
//printf("The current value of x,y is: %i %i \n", x,y);

printf("\n");
for(y=0;y<=5;++y) {printf("%d",y);}

printf("\n");
x=5;
x++;
printf("%i \n",x);

//x=5;
++x;
printf("%i \n",x);

return 0;

}

No comments: