Give the output of following programs.
Question # 1.
|
{
int a,b; // let a=5; b=6;
printf(“Enter values of a and b”);
scanf(“%d %d”,&a,&b);
printf(“a = %d b = %d”,a,b);
}
{
int i=10;
for(;i>=0; i--)
{
{
i -=2;
printf(“%d”, i);
printf(“%d”, i);
}
}
Question # 3.
|
{
int i = 1;
for (;;)
{
printf("%d", i++);
if (i >10)
break;
}
}
Question # 4.
|
void
main()
{
{
int i = 4;
switch (i)
{
default:
printf(“\n This is the Default case”);
case 1:
printf(“\n This is the Case 1”);
break;
printf(“\n This is the Case 1”);
break;
case 2:
printf(“\n This is the Case 2”);
break;
printf(“\n This is the Case 2”);
break;
case 3:
printf(“\n This is the Case 3”);
printf(“\n This is the Case 3”);
}
}
Question # 5.
void
main()
{
int i;
for(i=0; i<10; i++)
{
printf("%d\t ", i);
if (i%2 == 0) continue;
printf("\n");
}
int i;
for(i=0; i<10; i++)
{
printf("%d\t ", i);
if (i%2 == 0) continue;
printf("\n");
}
}
Expected output :
Question # 1
Enter the value of a and b 5
6
a = 5 b = 6
Question # 2
852-1
Question # 3
12345678910
Question # 4
This is the Default case
This is the Case 1
Question # 5
0 1
2 3
4 5
6 7
8 9
No comments:
Post a Comment