Predict the output of the following coding questions of C Language:
1. What is the output of the following code?
#include <stdio.h>
int main()
{
unsigned int a = 10;
a = ~a;
printf("%d\n", a);
}
2. What is the output of the following code?
int i=40;
extern int i;
int main()
{
do
{
printf("%d",i++);
}while (5, 4, 3, 2, 1, 0);
return 0;
}
3. What is the output of the following code?
int main()
{
int i;
for(i=10;i<=15;i++)
{
while(i)
{
do
{
printf("%d ",1);
if(i>>1)
continue;
}while(0);
break;
}
}
return 0;
}
4. What is the output of the following code?
void main()
{
double k = 0;
for (k = 0.0; k < 3.0; k++)
printf("Hello");
}
5. What is the output of the following code?
void main()
{
int i = 0;
for (i++; i == 1; i = 2)
printf("In for loop ");
printf("After loop\n");
}
6. What is the output of the following code?
void main()
{
int i = 0;
while (i < 10)
{
i++;
printf("hi\n");
while (i < 8)
{
i++;
printf("hello\n");
}
}
}
7. What is the output of the following code?
void main()
{
int i = 0, j = 0;
while (i < 5, j < 10)
{
i++;
j++;
}
printf("%d, %d\n", i, j);
}
8. What is the output of the following code?
void main()
{
int i, j;
for (i = 0;i < 5; i++)
{
for (j = 0;j < 4; j++)
{
if (i > 1)
break;
}
printf("Hi \n");
}
}
9. What is the output of the following code?
void main()
{
int i, j;
for (i = 0;i < 5; i++)
{
for (j = 0;j < 4; j++)
{
if (i > 1)
continue;
printf("Hi \n");
}
}
}
10. What is the output of the following code?
void main()
{
int i;
for(i = 2;i += 2; i <= 9; i +=2)
printf(“%d\n”, i);
}
Post A Comment:
0 comments: