You are on page 1of 5

Ôn tập 2

1) Which function definition will run correctly?


A. int sum(int a, int b)    {return (a + b);}
B. int sum(a; b) {return (a + b);}
C. int sum(a, b)    {return (a + b);}
D. int sum(int a, int b)    {return (a + b) };
2) Output of this program

A.x is 97
B.x is 98
C.x is 99
D.Run time error
Answer: 97
3) Output of this program

A. Implementation defined
B. -1
C. -3
D. Compile time error
4) A variable is called a global variable if
A. It is declared inside all functions, except main()
B. It is declared in addition to all functions including main()
C. It is declared outside all functions, except main()
D. It is declared inside main() function
Answer: B
5) Output of this program

A. 8
B. 7
C. Run time error
D. None of the mentioned
6) Output of this program

printf("C programing %s","Class by\n%s Sanfoundry","Wow");


A. C programming Class by
WOW Sanfoundry
B. C programming Class by\n%s Sanfoundry
C. C programming Class by
%s Sanfoundry
D. Compilation error
Answer: C
7) Which result of
strcmp(S1, S2) with S1 ="abcdefgh" and S2 = "abcdefdh"

A. 0
B. A negative integer.
C. None of the others
D. A positive integer.
Answer: D
8) What do the scanf("%d%*c", &number) statement do?
A. clear the buffer
B. swallow the new line symbol after the input.
C. swallow the buffer
D. swallow one character first
Answer: B
9) A variable declared in a function can be used in main
A. True
B. False
10) What will be the data type of the result of the following operation?
(float)a*(int)b / (long)*(double)d
A. int
B. long
C. float
D. double
11) The function double pow(double, double) is declared in the header file .......
A. stdio.h
B. stdlib.h
C. math.h
D. string.h
Answer: C
12) Which result of %[abcd] conversion specifier, used in the scanf function, with the input value is
dbafgha?
A. dba
B. dbaa
C. dbafgha
Answer: A
13) Which of these statements about arrays is true?
A. To refer to an element, we use the array name followed by parentheses (ngoặc đơn)
notation around the element index
B. The index can be an integer variable, an integer expression or an integer constant
C. A C- array can stored elements in different data types
D. Index numbering starts at 1 and extends to the size of the array
Answer: B
14) Output of this program

int a=1,b;
b= a++ + a++;
printf("%d",b);

A. 1
B. 2
C. 3
D. 4

Answer: 3
15) Output of this program

int a=1,b;
b= a++ + ++a;
printf("%d",b);
A. 1
B. 2
C. 3
D. 4
Answer: 4
16) Output of this program

int a=1,b;
b= ++a + a++;
printf("%d",b);
A. 3
B. 4
C. 5
D. 6

Answer: 5
17) Output of this program

int a=1,b;
b= ++a + ++a;
printf("%d",b);
A. 3
B. 4
C. 5
D. 6

Answer: 6
18) Output of this program

int a=1,b;
b= ++a + ++a + a++;
printf("%d",b);
A. 7
B. 8
C. 9
D. 10

Answer: 9
19) Output of this program

int a=1,b;
b= ++a + ++a + ++a;
printf("%d",b);
A. 7
B. 8
C. 9
D. 10

Answer: 10
20) Output of this program

int a=1,b;
b= ++a + ++a + --a;
printf("%d",b);
A. 7
B. 8
C. 9
D. 10
Answer: 8

You might also like