0 votes
79 views

What is the type of error (earliest phase) identified during the compilation of the following program ?

#include <stdio.h>
main( )
{
int x, y, z;
x = y = z = 10.3;
printf(“%c”, x);
}

asked
edited | 79 views
• No lexical error
• No syntax error
• Semantic error Reported
Why Semantic Error ?

In C, It will be typecasted as $x = y = z = 10$, and ASCII character corresponding $10$ will be printed. So, no problem in C.

But it would cause semantic error if it $x,y$ and $z$ were initialized as floats. rt??
Ya implicit type conversion is available in C..So no issue in C..But in languages which it does not support this feature..So there problem will come in type checking which is a part of semantic analysis phase..
yes, it will be error because it want to print int value in %c

+1 vote
1 answer
1
+4 votes
2 answers
2
0 votes
0 answers
3