a=0;
while(a<5)
printf("%d\n",a++);
how many times does the loop occurs?
a.infinite
b.5
c.4
d.6

Answers were Sorted based on User's Feedback



a=0; while(a<5) printf("%d\n",a++); how many times does the loop occurs? ..

Answer / bharath kumar

Hello,

The answer is b.

a=0+1=1
a=1+1=2
a=2+1=3
a=3+1=4
a=4+1=5

While a variable is storing the 5 result a is nither less
then are equal to 5 hence the application will come out of
the loop.So while loop had run 5 times.

Is This Answer Correct ?    28 Yes 4 No

a=0; while(a<5) printf("%d\n",a++); how many times does the loop occurs? ..

Answer / guest

b

Is This Answer Correct ?    20 Yes 5 No

a=0; while(a<5) printf("%d\n",a++); how many times does the loop occurs? ..

Answer / vikram

the output will be:
0
1
2
3
4
hence the loop will be executed 5 times,hence the answer is b

Is This Answer Correct ?    17 Yes 2 No

a=0; while(a<5) printf("%d\n",a++); how many times does the loop occurs? ..

Answer / deepu_ashu

as the value of "a" increases after printing the value.
so it will print the value
0
1
2
3
4
but after printing the value 4 ,it becomes 5 for the next iteration.
so the condition becomes false.
the loop will not execute any more.

Is This Answer Correct ?    12 Yes 1 No

a=0; while(a<5) printf("%d\n",a++); how many times does the loop occurs? ..

Answer / vignesh1988i

THIS LOOP OCCURS 5 TIMES. AT THE SIXTH TIME IT BECOMES FALSE

Is This Answer Correct ?    12 Yes 2 No

a=0; while(a<5) printf("%d\n",a++); how many times does the loop occurs? ..

Answer / sruthi

answer is b

Is This Answer Correct ?    9 Yes 1 No

a=0; while(a<5) printf("%d\n",a++); how many times does the loop occurs? ..

Answer / ankit rastogi

ans should be (a)infinite
bcoz every time a will be initialize with 0......
and increment values are displayed
a=1
a=2
a=3
a=4...................upto infinity......

Is This Answer Correct ?    4 Yes 3 No

Post New Answer

More C Interview Questions

main() { static char *s[]={"black","white","yellow","voilet"}; char **ptr[]={s+3,s+2,s+1,s}, ***p; p=ptr; **++p; printf("%s",*--*++p+3); }

1 Answers  


Can one function call another?

0 Answers  


Explain why c is faster than c++?

0 Answers  


int i =10 main() { int i =20,n; for(n=0;n<=i;) { int i=10 i++; } printf("%d", i);

6 Answers   HCL, Octal, SW,


What is RAM memory? and What is ROM?Who designed one is temparary and another is permanent?why they designed like that?By using far pointer which type data(whether hexadecimal)we can access?

1 Answers   Excel,






who developed c and why he developed c?

5 Answers  


how 2 compile & execute c program with out using editor?

2 Answers   HP,


What is the benefit of using an enum rather than a #define constant?

0 Answers  


Why c language?

0 Answers  


what is recursion in C

0 Answers   Cap Gemini,


what is memory leak?

3 Answers  


How can I remove the trailing spaces from a string?

0 Answers   Aspire,


Categories