0% found this document useful (0 votes)
29 views3 pages

Find Out The Outputs of The Following C Programs and Explain The Logic

The document provides the code for 5 C programs and asks to determine the output of each program and explain the logic. The programs include: 1) a recursive function that prints a static variable and calls main if the variable is not 0, 2) a for loop that prints numbers from 1 to 100, 3) code that assigns the result of pre- and post-decrement operators to variables and prints them, 4) code that performs arithmetic operations on variables using assignment, and 5) a conditional expression that prints the square of a variable if it is greater than another or divides the second variable by itself.

Uploaded by

umamaheshsjcet
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views3 pages

Find Out The Outputs of The Following C Programs and Explain The Logic

The document provides the code for 5 C programs and asks to determine the output of each program and explain the logic. The programs include: 1) a recursive function that prints a static variable and calls main if the variable is not 0, 2) a for loop that prints numbers from 1 to 100, 3) code that assigns the result of pre- and post-decrement operators to variables and prints them, 4) code that performs arithmetic operations on variables using assignment, and 5) a conditional expression that prints the square of a variable if it is greater than another or divides the second variable by itself.

Uploaded by

umamaheshsjcet
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Find out the outputs of the following c

programs and explain the logic!


#include<stdio.h>
1. main()
{
Static int c=5;
printf(“c=%d\n”,c--);
if(c)
main();
}
#include<stdio.h>
2.main()
{
register int i;
for(i=1;i<=100;i++)
printf(“%d\n”,i);
}
3. #include<stdio.h>
main()
{
int x=10,y;
y=--x--;
printf(“x=%d\ny=%d”,x,y);
}
#include<stdio.h>
4.main()
{
Int x=10,y=x,z=x;
y-=x;
z=-x;
t=-x;
printf(“y=%d\nz=%d\nt=%d”,y,z,t);
}
5. #include<stdio.h>
main()
{
int a=10,b=10;
printf(“ans=%d”,a>b?a*a:b/b);
}

You might also like