C Programming - Control Instructions - Discussion

Discussion Forum : Control Instructions - Point Out Correct Statements (Q.No. 9)
9.
Point out the correct statements are correct about the program below?
#include<stdio.h>
int main()
{
    char ch;
    while(x=0;x<=255;x++)
        printf("ASCII value of %d character %c\n", x, x);
    return 0;
}
The code generates an infinite loop
The code prints all ASCII values and its characters
Error: x undeclared identifier
Error: while statement missing
Answer: Option
Explanation:

There are 2 errors in this program.
1. "Undefined symbol x" error. Here x is not defined in the program.
2. Here while() statement syntax error.

Discussion:
12 comments Page 2 of 2.

Vinoth said:   1 decade ago
Khan you understand in while loop only condition is checked.

Eg:while(x>5).

Abid khan said:   1 decade ago
While statement work properly.

But x is not declared so while statement missing.


Post your comments here:

Your comments will be displayed after verification.