(Week 6) 2023 with complete solution
Who invented the C language?
Dennis Ritchie invented C at Bell Labs
When you compile a correct C program you get a machine executable file such as
a.out produced by the gnu compiler gcc.
True
Which is true:
1. #define is a preprocessor command often used to introduce named constants
2. double and goto are keywords declaring types.
3. return (0); is normally the last statement in main()
4. The file stdio.h is where the compiler finds scanf().
1, 3, 4
The statement printf("HELLO\t\tWORLD\n");
Prints HELLO WORLD followed by a new line
The expression PI radius radius would be used to compute
A circles area
In a format string for printf which would you use to print an int?
%d
The code
i = -10;
while ( i < 0)
{ ... do something ; i--; }
Displays a common error
its an infinite loop
The following program is suppose to write Hello World onto the screen but it has
syntax errors - find and correct.
#include <stdio.h>
int main(void)
{
printf(" Hello World\n");
return 0,
}
It should be return 0;
Assume the given declarations and fill in the value of the expression . int a = 3, b
= 4, c = 0, d = '1';
Expression: a % b
3
, Assume the given declarations and fill in the value of the expression . int a = 3, b
= 4, c = 0, d = '1';
Expression: b % a
1
Assume the given declarations and fill in the value of the expression . int a = 3, b
= 4, c = 0, d = '1';
Expression: a < b
1
Assume the given declarations and fill in the value of the expression . int a = 3, b
= 4, c = 0, d = '1';
Expression: c < b && a > 3
0
Assume the given declarations and fill in the value of the expression . int a = 3, b
= 4, c = 0, d = '1';
Expression: a / b > c
0
Assume the given declarations and fill in the value of the expression . int a = 3, b
= 4, c = 0, d = '1';
Expression: c = a++
3
Assume the given declarations and fill in the value of the expression . int a = 1, b
= 2, c = 3;
Expression: a - b * c
-5
Assume the given declarations and fill in the value of the expression . int a = 1, b
= 2, c = 3;
Expression: c / a * b
6
Assume the given declarations and fill in the value of the expression . int a = 1, b
= 2, c = 3;
Expression: a++ + --b
2
Assume the given declarations and fill in the value of the expression . int a = 1, b
= 2, c = 3;
Expression: b = a = c
3