C Programming - Control Instructions - Discussion

Abid Khan said: (Nov 27, 2010)  
While statement work properly.

But x is not declared so while statement missing.

Vinoth said: (Mar 14, 2011)  
Khan you understand in while loop only condition is checked.

Eg:while(x>5).

Praveen said: (Jan 16, 2012)  
Ambiguous Answers, X is undeclared and while statement is wrong.
Depends on Compiler to show which error first.
How it parses the program.

In option both x undeclared and while error should be as one answer.

Balaram Sahu said: (Nov 17, 2014)  
Syntax of while statement is wrong and also x is not declared in the programme.

Jay said: (Oct 10, 2015)  
How to know which error will come first?

Guddu said: (Apr 23, 2016)  
It showing error as,

sh-4.3$ gcc -o main *.c
main.c: In function 'main':
main.c:5:11: error: 'x' undeclared (first use in this function)
while(x=0;x<=255;x++)
^ main.c:5:11: note: each undeclared identifier is reported only once for each function it appears in,
main.c:5:14: error: expected ')' before ';' token
while(x=0;x<=255;x++)

So I think the answer should be C only.

Raj said: (Nov 3, 2016)  
Please make it as simple and understandable. What is the correct format of while loop?

Mage said: (Dec 28, 2016)  
Simply explain in a program.

Mashkur Khadmi said: (Apr 7, 2017)  
err.c: In function \'main\':
err.c:5:11: error: \'x\' undeclared (first use in this function)
while(x=0;x<=255;x++)
^
err.c:5:11: note: each undeclared identifier is reported only once for each function it appears in
err.c:5:14: error: expected \')\' before \';\' token
while(x=0;x<=255;x++)
=======================================================

First, the compiler will check during compilation, after while loop it will check for ' x ' which is undeclared.

It will generate error, And next will be the While loop syntax error.

Srinivas said: (Apr 15, 2017)  
Your answer is wrong this program.

The first error is x undeclared identifier.

Rohan said: (Jun 10, 2018)  
@All.

char ch;
Step 1: a variable (ch) is declared as a character.

while(x=0;x<=255;x++)
printf("ASCII value of %d character %c\n", x, x);

Step 2: (i) x is undeclared and this error comes first when you run the computer...
(ii) syntax of while loop is wrong.
Instead it is like this
->> while(x<=255)
{
statement(s);
}

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.