Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

College of Agriculture, Science & Technology, Lafia

Department: Computer Science


COM 121: Programming Using C Language
Time: 40 Minutes Semester: Second Total marks: 20
Answer all question questions.
All questions carry 0.8 mark each

1. Short int means 8. What will be the output of the following code
a) Qualifier snippet?
b) Short is the qualifier and int is the basic data type
c) data type
d) All of the above
2. Which of the following is used for comments in
C++?
a) /* comment */
b) // comment */
c) // comment
d) both // comment or /* comment */
3. Which of the following is a correct identifier in
C++?
a) VAR_1234
a) 3 5
b) $var_name
b) 3 3
c) 7VARNAME
c) 5 5
d) 7var_name
d) 5 3
4. C variable cannot start with a
9. What is the output of this statement
a) number
"printf("%d", (a++))"?
b) Both A and C
a) The value of (a + 1)
c) Any special symbol except underscore
b) The current value of a
d) None of the above
c) Error message
5. Which is valid C expression?
d) Garbage
a) int my_num = 100,000;
10. What is the result after execution of the
b) int my_num = 100000;
following code if a = 10, b = 5, and c = 10?
c) int my num = 1000;
If ((a > b) && (a <= c))
d) int $my_num = 10000;
a = a + 1;
6. What is an example of iteration in C?
else
a) for
c = c+1;
b) while
a) a = 10, c = 10
c) do-while
b) a = 11, c = 10
d) all of the mentioned
c) a = 10, c = 11
7. What is #include <stdio.h>?
d) a = 11, c = 11
a) Preprocessor directive
11.Which one of the following is a loop construct
b) Inclusion directive
that will always be executed once?
c) File inclusion directive
a) for
d) None of the mentioned
b) while
c) switch
d) do while
12. What will the result of num variable after 19. Which of the following is not an arithmetic
execution of the following statements? operation?
int num = 58; a) x * = 65;
num % = 11; b) x / = 42;
a) 3 c) x % = 2;
b) 5 d) x ! = 56;
c) 8 20. Which of the following declaration is incorrect
d) 11 in C language?
13. What is the maximum number of characters a) scanf("%d%d", a, b);
that can be held in the string variable char b) scanf("%d%d", a b);
address line [40]? c) scanf("First %d Second %d", &a, &b);
a) 38 d) scanf(" %d%d", &x,&y);
b) 39 21. Which of the following statements are correct
c) 40 about string?
d) 41 1. The format specifier %s is used to print a
14. Study the following statement string.
#include <stdio.h> 2. The length of the string can be obtained by
int main() strlen().
{ 3. The pointer cannot work on string.
int *ptr, a = 10; 4. A string is a collection of characters
ptr = &a; terminated by '\0'.
*ptr += 1; a. 1, 4
printf("%d,%d/n", *ptr, a); b. 1, 2, 3
} c. 1, 2, 4
What will be the output? d. 2, 3, 4
a) 10, 10 22. What are strings in C programming?
b) 10, 11 a) Individual variables
c) 11, 10 b) Group of function
d) 11, 11 c) Group of character type variables in array form
15. Given the following statement, what will be d) All of the above
displayed on the screen? 23. What is the output of the following code
int * aPtr; snippet?
*aPtr = 100;
cout << *aPtr + 2;
a) 100
b) 102
c) 104
d) 108
16. Study the following array definition
int num[10] = {3, 3, 3}; a) 2
Which of the following statement is correct? b) 15
a) num[9] is the last element of the array num c) 16
b) The value of num[8] is 3 d) 18
c) The value of num[3] is 3 24. Functions can only be called either by value or
d) None of the above reference.
17. A global variable is declared __________. a. True
a) Outside of the function b. False
b) Inside of the function 25. What is built in library function for comparing
c) With the function the two strings?
d) Anywhere in the program a) strcmp()
18. Who defines the user-defined function? b) equals()
a) Compiler c) str_compare()
b) Computer d) string_cmp()
c) Compiler library
d) Users

You might also like