Study questions covering C Chapters 1-5 Flashcards
1
Q
What is wrong with the following code? #include /*This is a directive line*/ main /* This function will be automatically called*/ (void/* I do not have arguments to pass*/) { /* This is the first line in the program /* I am so excited to write this program */ printf(“Hello world\n”)} /* Finally I am done with it /* But I am not sure why it does not work :-( */ }
A
There is no semi colon after the call of the printf function statement.
There is an extra } after the printf statement.
2
Q
Which of the following are legal C identifier?
100_bottles, _100bootles, one-hundred-bottles, one_hundred_bottles,
one_hundred_bottles, one__hundred__bottles, one__hundred__bottles__, If, main,
Printf, and while.
A
_100_bootles, one_hundred_bottles, one_hundred_bottles_, one\_\_hundred\_\_bottles, one\_\_hundred\_\_bottles\_\_, If, main, Printf,