Jump to content

C programming language question?

Featured Replies

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++)

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

Archived

This topic is now archived and is closed to further replies.

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.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.