Did you make a typo with "var" vs "intvar"??
Assuming you made a typo the output is "54321".
Give the output of program in c-lang -main() { static intvar=5; printf("%d",var--) if (var) main(); }
already they have given the answer.
Output would be 54321.
Why?
since the declaration of the variable is static though, we have a decrement var-- and which makes the program to display it 54321.
Reply:intvar must be separated
semicolon must be added for print command
Then output will be
5
4
3
2
1
Here is C++ version of the program:
#include %26lt;iostream%26gt;
using namespace std;
int main()
{ static int var=5;
cout %26lt;%26lt;"\n" %26lt;%26lt; var--;
if (var) main();
cout %26lt;%26lt;endl %26lt;%26lt; endl;
system("pause");
}
Reply:output: 54321
Reply:I concur...
54321
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment