You are on page 1of 4

Question 1.

Predict the output of the following codes:

1. #include<stdio.h>
int main()
{
int a=5;

while(a=123)
{
printf("Graphic Era\n");
break;
}
printf("Hill University");

return 0;
}

2. #include<stdio.h>
int main()
{
int a=32;

do
{
printf("%d ", a);
a++;
if(a > 35)
break;
}while(1);

return 0;
}

3. #include<stdio.h>
int main()
{
int k, j;

for(k=1, j=10; k <= 5; k++)


{
printf("%d ", (k+j));
}

return 0;
}

4. #include<stdio.h>
int main()
{
int k;

for(;;)
{
printf("Gehu\n");
break;
}
return 0;
}

5. #include<stdio.h>
int main()
{
int k;

for(printf("FLOWER "); printf("YELLOW "); printf("FRUITS "))


{
break;
}

return 0;
}

6. What will be the output of following program ?

#include <stdio.h>
void main()
{
int tally;
for(tally=0;tally<10;++tally)
{
printf("#");
if(tally>6)
continue;
printf("%d",tally);
}
}
7. # include <stdio.h>
int main()
{
int i=0;
for(i=0; i<20; i++)
{
switch(i)
{
case 0:
i+=5;
case 1:
i+=2;
case 5:
i+=5;
default:
i+=4;
break;
}
printf("%d ", i);
}

getchar();
return 0;
}

8. If originally x=4,y=0, and z=2, what is the value of x,y, and ,z after executing the
following code?
#include<stdio.h>
int main()
{
int x=4,y=0,z=2;
if(z ==0 || x && !y)
if(!z)
y=1;
else
x=2;
printf("x=%d\ny=%d\nz=%d\n",x,y,z);
return 0;
}
Question 2 : WACP to print the following pattern:
*
***
*****
*******

*
* *
* *
* *
*******

You might also like