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

What is the best way of making my program efficient?

0 Answers  


What is the heap?

0 Answers  


Identify the operators that is not used with pointer a. && b. # c. * d. >>

2 Answers  


What is the difference between test design and test case design?

0 Answers  


struct screen_pos{ int row, col } ;move_right(cursor)struct screen_pos *cursor;{ cursor.col++; } /* This statementhas a syntax error */What is the correct statement a) cursor.col = cursor.col + 1; b) col.cursor++; c) *cursor.col++; d) pointer

0 Answers  






what is purpose of fflush(stdin) function

4 Answers  


What are the 5 elements of structure?

0 Answers  


how much salary u want ? why u join in our company? your domain is core sector why u prefer software ?

0 Answers   Gopaljee, TCS,


3. Program to print all possible substrings. ex: String S St Str Stri Strin String t tr tri trin tring r

3 Answers   Huawei,


difference between my-strcpy and strcpy ?

3 Answers   Geometric Software, IIM, Infosys,


#include<stdio.h> main() { char *p1; char *p2; p1=(char *) malloc(25); p2=(char *) malloc(25); strcpy(p1,"Ramco"); strcpy(p2,"Systems"); strcat(p1,p2); printf("%s",p1); } Tell me the output?

6 Answers   Ramco,


How important is structure in life?

0 Answers  


Categories