1. Predict the output of the code:
#include<stdio.h>
main()
{
char x;
int y;
x=100;
y=125;
printf("%c\n",x);
printf("%c\n",y);
printf("%d\n",x);
}
OUTPUT:
2. Point out the error if any in the following program:
#include<stdio.h>
main()
{
int i=1;
switch(i)
{
printf("HELLO");
case 1:
printf("Individualists unite!");
break;
case 2:
printf("\n Money is the root of all wealth");
break;
}
}
OUTPUT :
Individualists unite!
printf statement before the case begins does not give any error but it is ignored.
3. Point out the error if any in the following program:
#include<stdio.h>
main()
{
int i=4,j=2;
switch(i)
{
case 1:
printf("\n This is case 1");
break;
case j:
printf("\n This is case j");
break;
}
}
OUTPUT:
Constant expression is required in case j, we cannot use j.
#include<stdio.h>
main()
{
char x;
int y;
x=100;
y=125;
printf("%c\n",x);
printf("%c\n",y);
printf("%d\n",x);
}
OUTPUT:
2. Point out the error if any in the following program:
#include<stdio.h>
main()
{
int i=1;
switch(i)
{
printf("HELLO");
case 1:
printf("Individualists unite!");
break;
case 2:
printf("\n Money is the root of all wealth");
break;
}
}
OUTPUT :
Individualists unite!
printf statement before the case begins does not give any error but it is ignored.
3. Point out the error if any in the following program:
#include<stdio.h>
main()
{
int i=4,j=2;
switch(i)
{
case 1:
printf("\n This is case 1");
break;
case j:
printf("\n This is case j");
break;
}
}
OUTPUT:
Constant expression is required in case j, we cannot use j.
No comments:
Post a Comment