Jump to content

Recommended Posts

Posted

1)What is the output of this code fragment ?

i=1;

while (i<128) {

printf ("%d,i) ;

i *=2;

}

 

2) What is the output of this code fragment?

i=9384;

do {

printf ("%d",i );

i /=10;

} while (i>0) ;

 

3)Same question

for (i =5,j=i-1;i>0,j>0;--i,j=i-1)

printf ("d",i);
4)Same question
for (i=10;i>=1,i /=2)

printf("%d",i++)

Posted (edited)

If this is homework, we're not supposed to help by doing your assignments for you. Have you tried running the code yourself? What output did you get?

 

Try running it here, see what it does for yourself:

http://codepad.org/

 

Edit: For clarity, add \n after %d, as such: "%d\n". Also, you'll need to put the code in a main function, just like a real program.

Edited by pwagen

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.