Capgemini
Company
Programming
Program
#include
int r();
int main(){
for(r();r();r()) {
printf("%d ",r());
}
return 0;
}
int r(){
int static num=7;
return num--;
}
Read Solution (Total 15)
-
- Answer : 5 2
- 10 years agoHelpfull: Yes(13) No(8)
- Ans:
-------
5 2
Explanation:
-----------------
1st iteration:for(7 ; 6 ; this portion will not execute){printf(5)}
2nd iteration:for(this portion will not execute; 3 ; 4){printf(2)}
3rd iteration:for(this portion will not execute; 0 ; 1)//As the condition expression become 0 the condition will be false and it will not execute the printf function inside the loop.
*static variable will initialized for the first call of r().......after each call it will not execute the "static num=7" expression.As the return is "num--" so first it will return then will decrement the value of num. - 8 years agoHelpfull: Yes(11) No(0)
- please give explanation for ans 5 2
- 9 years agoHelpfull: Yes(8) No(1)
- syntax error.because in for loop their is no boolean condition...
- 10 years agoHelpfull: Yes(5) No(7)
- do programming qsn coming in capgemini?????
- 10 years agoHelpfull: Yes(4) No(7)
- please elaborate guys
- 10 years agoHelpfull: Yes(2) No(1)
- 5 2 is correct
- 9 years agoHelpfull: Yes(2) No(1)
- it is an error .there is no predefined directive.if stdio.h is there then the o/p is 5 2
- 7 years agoHelpfull: Yes(2) No(0)
- Correct Solution: It will go on printing 7 until time out. (Coded and checked)
- 9 years agoHelpfull: Yes(1) No(11)
- syntax error.
correct ans: #include
- 9 years agoHelpfull: Yes(1) No(2)
- vikas
ans:5 - 10 years agoHelpfull: Yes(0) No(5)
- syntax error.
correct ans: #include - 9 years agoHelpfull: Yes(0) No(4)
- can any one explain this output clearly?
- 9 years agoHelpfull: Yes(0) No(1)
- output 5 2
- 7 years agoHelpfull: Yes(0) No(1)
- the outpuut is 5,2
in the initialisation section of for loop(remains 7), then at condition(6), and then goes under the loop to print 5, again in the increment section of the loop, it becomes4, and continuing, it last prints 2, and num is 1 - 6 years agoHelpfull: Yes(0) No(1)
Capgemini Other Question