- What is the option that instructs the gcc compiler to print
out all warnings?
Hints:
GCC: run the command gcc --help=warnings | grep -i 'enable.*warning'
.
Clang: run the command clang --help | grep -i 'enable.*warning'
and try to figure out.
- Name the comparison operators in C.
- Rewrite this piece of code,
(a>b?a:b)
, using the if
statement.
- What is your shell?
Hints: try echo $0
, echo $SHELL
, ps --pid "$$"
.
- If you use mathematical functions from
complex.h
, do you
need to link your program with -lm
option?
Hint: man complex|grep '\-lm'
.
- What will the following piece of code print?
int i=1; printf("%i\n",i++); printf("%i\n",++i);
Explain.
- How about
int i=1; printf("%i %i\n",i++,++i);
Hint:
compile with -Wall
.
- Rewrite the loop
while(condition)body
using the for
loop.
- Rewrite the loop
for(init;cond;inc)body
using the while
loop.
- Rewrite the loop
do body while(condition);
using the for
loop.
- Is this a valid C-code?
if(0) printf("0 is true\n");
else printf("0 is false\n");
if(7) printf("7 is true\n");
else printf("7 is false\n");
Hint: Wikipedia → C syntax → Selection statements.
- Does C have a boolean (that is having one of two values, "true" or "false") type?
Hint: Wikipedia → Boolean data type →C.