in Compiler Design edited by
759 views
2 votes
2 votes
identify the type of error

int main()

{

int gate,exam,rank;

gate=exam=rank=10.3;

printf("%c",gate);

}

a)lexical error

b)syntax error

c)semantic error

d)none of these
in Compiler Design edited by
759 views

5 Comments

semantic error ?
0
0
Ahhhh ! no error but it is giving some wierd negative answers for %d.

not even working as suggested here in the link.

http://stackoverflow.com/questions/19353686/multiple-assignment-in-one-line
0
0

According to the definitioon here http://stackoverflow.com/questions/7849684/what-is-semantic-errors-in-c-language-give-some-examples this should be a semantic error. Can someone confirm?

0
0
Why semantic ?
0
0

@Kapil According to the definition in that link, "Semantic errors. These are valid code the compiler understands, but they do not what you, the programmer, intended." Here it doesnt seem like the programmer intended to print the new line character. However, I am not sure if this is the definiton that is usually followed for semantic errors.

0
0

1 Answer

0 votes
0 votes
It won't print anything as ASCII character for 10.3/10 is newline; so it won't print anything , but go to the next line. I don't think any error is present. So, D
edited by

2 Comments

it is just 10 as 10.3 gets implicitly type casted to 10 on assignment to an int variable.
1
1
Sorry sir; silly mistake; ASCII value of 10 is new line; so it will not print anything I guess and simply mark the beginning of a new line?
0
0