Quiz
C programming basics: variables, functions, loops
Create a free account to finish this quiz
Save your progress and see your final score.
Already have an account? Sign in
Questions in this quiz (14)
1Declaring variables
Which of the following statements correctly declare variables?- Aint sum = 5;
- Bsum = 7;
- Cvoid x = 31;
- Ddouble d = 2.5;
2What is the result of 45 / 4?
- A11.25
- B12
- C10
- D11
3Declaring functions
Which of the following declare a function that sums two numbers and gives the result to the caller?- Adouble sum(double d1, double d2) { return d1 + d2; }
- Bvoid sum(double d1, double d2) { return d1 + d2; }
- Cdouble sum(double d1, double d2) { d1 + d2; }
- Dvoid sum(double d1, double d2) { sum = d1 + d2; }
4Character values
Which of the following is the correct expression of the character 7?- A7
- B'7'
- C"7"
- D<7>
5Assignment operator
________ is the assignment operator.- A=
- B:=
- C=:
- D==
6Printing characters
Suppose c is a char variable with the value 'e'. What is the printout of the statement printf("%c", +
+c)?- Ac
- Bd
- Ce
- Df
7Compiler checks
The compiler checks ________.- ASyntax errors
- BRunetime errors
- CLogical errors
8Declaring strings
Which of the following statements correctly declare a C string?- Astring s = "Hello, World!";
- Bchar s = "Hello, World";
- Cchar s[] = "Hello, World!";
- Dstring s = 'Hello, World!';
9Bits and bytes
One byte usually has ________ bits.- A4
- B8
- C12
- D16
10Main function
Which of the following are valid main functions?- Aint main() { return 0; }
- Bvoid main() { }
- Cint main() { }
- Dvoid main() { return 0; }
11Comments
Which of the following are valid C99 comments?- A// Comment here
- B/* Comment here */
- C/* Comment here
- D// Comment here */
12Local variables
Local variables exist:- AFrom the beginning of the scope to the end of the scope
- BFrom where they are declared to the end of the scope
- CFrom the beginning of the function to the end of the function
- DFrom where they are declared to the end of the function
13For loop
What is the output of the following code:
int i = 0;
for (i = 0; i < 10; i++) { }
printf("%i", i);- A9
- B10
- C11
14Reading values
Which of the following statements correctly use scanf()?- Aint i; scanf("%i", &i);
- Bint i; scanf("%i", i);
- Cdouble d; scanf("%d", &d);
- Ddouble d; scanf("&d", &d);
Information
- Description
- Quiz on Untitled, created by Morten J. on 07/12/2018.
- Author
- Morten J.
- Language
- English
- Views
- 0
- History
- Created on 7 Dec 2018 · updated on 7 Dec 2018
- Rating
- No ratings yet Rate this quiz