What is the output of below code?
main()
{
static in a=5;
printf("%3d",a--);
if(a)
main();
}
Answers were Sorted based on User's Feedback
54321
here main() is called again in main function
this leads to recursion....
the function is called until a become 0.
value is retained as static key word is used.
not much clear about usage of "%3d"
| Is This Answer Correct ? | 10 Yes | 1 No |
Answer / amol subhash kumbhar
Output is:- 5 4 3 2 1 (This Manner)
In main()
Static is the Preserves Keyword Used to Statically allocate
the memory allocation
%3d means the 3 space are allocate in the output like as 5
4 3 2 1
main() :- main function called in main function means
recursion is applied
| Is This Answer Correct ? | 5 Yes | 0 No |
Answer / pratik panchal
output:5 4 3 2 1
static int store the value of variable for once and
periodically changes its value as the variable value changes
and a-- is done so the assigned value on the next line will
automatically overwrite the value of a.
%3d means print 5 then 2 spaces and 4 and so on..,.main is
called until if statement gets false..if(5) is a true
condition.
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / moloy mondal
the output will be infinite no. of 5s ..bcoz integer a is
static its value wont b changed ever..
| Is This Answer Correct ? | 2 Yes | 4 No |
Which of these functions is safer to use : fgets(), gets()? Why?
what is the output of following question? void main() { int i=0,a[3]; a[i]=i++; printf("%d",a[i] }
Write a program to produce the following output in c language? 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1
what is the output of the following code? main() { int I; I=0x10+010+10; printf("x=%x",I); } give detailed reason
Write a C program to check a number even or odd, without using any relational, arithmetic operator and any loops.
plz let me know how to become a telecom protocol tester. thank you.
Write a function to find the area of a triangle whose length of three sides is given
What is #define used for in c?
what is the difference between char * const and const char *?
How can I call system when parameters (filenames, etc.) Of the executed command arent known until run time?
how can be easily placed in TCS.
What is #define in c?