MCQs
space, comma and $ cannot be used in a variable name.
It results in an error since x is used without declaring the variable x.
Output:
$ cc pgm1.c
pgm1.c: In function 'main':
pgm1.c:4: error: 'x' undeclared (first use in this function)
pgm1.c:4: error: (Each undeclared identifier is reported only once
pgm1.c:4: error: for each function it appears in.)
Since y is already defined, redefining it results in an error.
Output:
$ cc pgm2.c
pgm2.c: In function 'main':
pgm2.c:5: error: redefinition of 'y'
pgm2.c:4: note: previous definition of 'y' was here
A variable name cannot start with an integer, along with that the C compiler
interprets the '-' and '?' as a minus operator and a question mark operator respectively.
A C program can have same function name and same variable name.
$ cc pgm3.c
$ a.out
3
#define PI 3.14 is a macro preprocessor, it is a textual substitution.