top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the equivalent code of the following statement in WHILE LOOP format?

+2 votes
2,066 views
for (a=1; a<=100; a++)

printf ("%d\n", a * a);
posted Dec 2, 2014 by Vinitha

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote
a=1;

while (a<=100) {

printf ("%d\n", a * a);

a++;

}
answer Dec 2, 2014 by Shivaranjini
For Linux,
You can not put semicolon inside the bracket of while();
Hi all ,I am not getting that how this program is executing .. can you run it on ideone.com after removing all errors with comments? it isn't supporting gcc so on which compiler you ran this code?
did you run it on turboc++?
0 votes

For Linux,,,

It will show syntax error..
you can not write like that..

Correct Syntax is;

for(initialization ; condition checking ; action)

answer Dec 10, 2014 by Chirag Gangdev
Similar Questions
–1 vote
while(i<10);
{
  i++;
  printf("%d,\n", i);
}

Loop does not run for 10 iterations, what is the error?

+3 votes

While(0) means dont enter into it, but why you want to have while(0) in c code. Any suggestion.

Asked in the interview today.

...