Answer to Question #74495 in C for Sushmaswaraj Udatha

Question #74495
#include<stdio.h>
int main()
{
int n;
for(n = 7; n!=0; n--)
printf("n = %d", n--);
getchar();
return 0;
}

anyone tell the o/p ??
1
Expert's answer
2018-03-13T08:47:23-0400
#include <stdio.h>

int main()
{
int n; // declare the variable

// this is the infinity loop because n will never be 0
/*for(n = 7; n != 0; n--)
printf("n = %d", n--);*/

// the right code is next:
// now we check is the n greater than 0
for(n = 7; n >= 0; n--)
printf("n = %d\n", n--);

// wait for the input from user
getchar();
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS