C
Programming and Technical
Programming
Output
Q. What is the output of the following program?
void main(){
int a=1;
while(a++ <= 1)
while(a++ <= 2);
printf("%d",a);
}
Read Solution (Total 23)
-
- ans=5
the program works as
while(a++ - 11 years agoHelpfull: Yes(10) No(5)
- ans:5 while(a++
- 11 years agoHelpfull: Yes(4) No(6)
- Syntax error ending brace for while and main is not found
- 11 years agoHelpfull: Yes(3) No(9)
- ans 3 a++ means the value of a will be displayed and later incremented,after 1st while loop the value of a becomes 2 later after second while loop it increments and prints 3
- 11 years agoHelpfull: Yes(3) No(8)
- 5
while(a++ - 10 years agoHelpfull: Yes(2) No(1)
- 3,value of a will increment 2 times
- 11 years agoHelpfull: Yes(1) No(4)
- Compile term error....semicolon(;) after while will give compile term error
- 11 years agoHelpfull: Yes(1) No(3)
- Solution:5
Given programme can be write as
void main()
{
int a=1;
while(a++ - 10 years agoHelpfull: Yes(1) No(1)
- answer is 4 because first while loop contains another while loop.
first, outer loop increments a by 1 after checking the condition
now condition is true so inner loop checks the condition and increments a by 1 here a becomes 3
now in outer loop condition become false and a incremented by 1 so finally a is 4 - 11 years agoHelpfull: Yes(0) No(1)
- since while a++ is post addition a=1 till it reaches printf statement so a=1.
- 11 years agoHelpfull: Yes(0) No(2)
- ans:3
a=1then first while loop (a++ - 11 years agoHelpfull: Yes(0) No(1)
- first while execute 1 time
secand while execute 2 times
ans a=3 - 10 years agoHelpfull: Yes(0) No(0)
- Ans is: 5
- 10 years agoHelpfull: Yes(0) No(1)
- Q. What is the output of the following program?
void main(){
int a=1;
while(a++ - 10 years agoHelpfull: Yes(0) No(0)
- ans is 5
first while become inner loop & second while become outer loop.i'e according to nested loop program will work. - 10 years agoHelpfull: Yes(0) No(0)
- output:5
Explaination:
Same code we write as:
void main()
{
}
- 10 years agoHelpfull: Yes(0) No(4)
- ans is 5
put int datatype instead of void
int main(){
int a=1;
while(a++ - 10 years agoHelpfull: Yes(0) No(0)
- 3
I have done it .
- 10 years agoHelpfull: Yes(0) No(0)
- 3 , a++ becomes 2 after comparison ,, again with 2 ,it will become 3 .
hence 3 get printed
- 8 years agoHelpfull: Yes(0) No(1)
- pls,any one give clear explanation.
- 7 years agoHelpfull: Yes(0) No(0)
- When first a++ is executed in first while...Post incremented to 2 and in next while loop checks it and post increments and value is 3 and semicolon (separate r) is executed and once again while is executed so now condition fails but 3 became for becoz of post increment again
- 6 years agoHelpfull: Yes(0) No(0)
- ans: 5
first while loop condition------while(1 - 6 years agoHelpfull: Yes(0) No(0)
- the answer is 3
- 5 years agoHelpfull: Yes(0) No(0)
C Other Question