C
Programming and Technical
HR Interview
Interview
main()
{
static int var = 5;
printf("%d ",var--);
if(var)
main();
}
find output
Read Solution (Total 7)
-
- Output will be:
5 4 3 2 1 - 8 years agoHelpfull: Yes(2) No(1)
- output=1;
I have done it - 10 years agoHelpfull: Yes(1) No(3)
- output will be=1
- 7 years agoHelpfull: Yes(1) No(1)
- 54321
When static storage class is given, it is initialized once. The change in the value of a static variable is retained even between the function calls. Main is also treated like any other ordinary function, which can be called recursively. - 4 years agoHelpfull: Yes(1) No(0)
- output will be:
5 4 3 2 1 - 8 years agoHelpfull: Yes(0) No(1)
- 5 4 3 2 1
- 8 years agoHelpfull: Yes(0) No(1)
- 54321 every time it will be called untile it becomes 0
- 8 years agoHelpfull: Yes(0) No(1)
C Other Question
Predict the output or error(s) for the following programmes:
void main()
{i
nt const * p=5;
printf("%d",++(*p));
}
Answer: Compiler error: Cannot modify a constant value.
Explanation: p is a pointer to a "constant integer". But we tried to change the value of the
"constant integer".
38. main()
{
char s[ ]="man";
int i;
for(i=0;s[ i ];i++)
printf("n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
}
main()
{i
nt c[ ]={2.8,3.4,4,6.7,5};
int j,*p=c,*q=c;
for(j=0;j