1)Program:
main()
{
int a=2,b=3;
printf("%d",++(a*b+1);
}
Output: compile time error
Explanation : -- / ++(expression) will not allow
2)Program:
main()
{
int x=6;
if(x-6)
printf("welcome");
printf("%d",x);
else
printf("learner");
}
Output: error
Explanation : there is no braces for if condition
3)Program:
main()
{
int x=6;
if(x-6)
{
printf("welcome");
printf("%d",x);
}
else
printf("learner");
}
Output: learner
Explanation : if (0) means condition false so it prints learner
4)Program:
main()
{
float a=3.14;
printf("%f",a%2);
}
Output: compile time error
Explanation : float will not support % operator
5)Program:
int initializer (void)
{
return 50;
}
int main()
{
static int i=initializer();
printf("value of i =%d",i);
getchar();
return 0;
}
Output: compile time error
Explanation : In c static variables can only be initialized using constant literals
No comments:
Post a Comment