400 Câu hỏi trắc nghiệm lập trình C/C++ có đáp án (Phần 2)
50 câu hỏi
Which of the following functions compares two strings?
compare();
stringcompare();
cmp();
strcmp();
Chọn D
Which of the following adds one string to the end of another?
append();
stringadd();
strcat();
stradd();
Chọn C
In which standard library file is the function printf( ) located?
stdio.h
conio.h
stdlib.h
ouput.h
Chọn A
Which function is used to read the input from console?
scanf( )
printf( )
getch( )
Chọn B
Which of the following are NOT relational operator?
>
>
<=
None above
Chọn D
In the C program, the first statement that will be executed?
The first statement of main( )
The first statement of program
The first statement after the comment /**/
The first statement of end function
Chọn A
Why are a function phototypes useful?
Because they tell the complier that a function is declared later
Because they make program readable
Because they allow the programmer to see a quick list of function in the program along with the argument for each function.
All of the above
Chọn A
Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1?
rem = 3.14%2.1;
rem = fmod(3.14, 2.1);
rem = modf(3.14, 2.1);
Remainder cannot be obtain in floating point division.
Chọn B
Which of the following is not user define data type?
1
2
3
1 & 2 & 3
Chọn B
Identify which of the following are declarations
1
2
3
1 and 3
Chọn D
Is the following statement a declaration or definition?
Declaration
Definition
A & B
Chọn A
Is there any difference between following declarations?
Both are identical
No difference, except extern int fun( ); is probably in another file
int fun( ); is overrided with extern int fun( );
None of these
Chọn A
In the following program where is the variable a getting defined and where it is getting declared?
Extern int a is declaration, int a = 20 is the definition
Int a = 20 is declaration, extern int a is the definition
Int a = 20 is definition, a is not defined
a is declared, a is not defined
Chọn A
What are the types of linkages?
Internal and External
External, Internal and None
External and None
Internal
Chọn B
Which of the following special symbol allowed in a variable name?
* (asterisk)
| (pipeline)
– (hyphen)
_ (underscore)
Chọn D
By default a real number is treated as a
float
double
long double
far double
Chọn B
How would you round off a value from 1.66 to 2.0?
ceil(1.66)
floor(1.66)
roundup(1.66)
roundto(1.66)
Chọn A
Is there any difference in the following declaration?
Yes
No
Chọn A
A long double can be used if range of a double is not enough to accommodate a real number?
True
False
Chọn B
A float is 4 byte wide, whereas a double is 8 byte wide
True
False
Chọn A
Size of short integer and long integer can be verified using the sizeof( ) operator
True
False
Chọn A
If the definition of external variable occurs in the source file before its use in a particular function, then there is no need for an extern declaration in the function
True
False
Chọn A
Global variable are available to all functions. Does there exist a mechanism by way of which it available to some and not to others
Yes
No
Chọn B
Size of short integer and long integer would vary from one platform to another
True
False
Chọn B
A float occupies 4 bytes. If the hexadecimal equivalent of these 4 bytes A, B, C and D, then when this float is stored in memory in which of the following order do these bytes gets stored?
ABCD
DCBA
0xABCD
Depend on big endian or little endian architecture.
Chọn D
What are the difference types of real data type in C?
float, double
short int, double, long int
float, double, long double
double, long int, float
Chọn C
What will be the ouput of the program?
1.000000 2.000000
1.500000 1.000000
2.000000 1.000000
1.300000 2.000000
Chọn C
Which library will you add in the following program to work it correctly?
math.h
stdlib.h
log.h
dos.h
Chọn A
What will you do to treat the constant 3.14 as a long double?
use 3.14LD
use 3.14L
use 3.14DL
use 3.14LF
Chọn B
What will you do to treat the constant 3.14 as a float?
use float(3.14f)
use 3.14f
use f(3.14)
use (f)(3.14)
Chọn B
We want to round off x, a float, to an int value, The correct way to do is:
y = (int)(x + 0.5)
y = int(x + 0.5)
y = (int)x + 0.5
y = (int)((int)x + 0.5)
Chọn A
What will be output of the program?
1.670000e+000, 1.670000, 1.67, 1.670000,
Complier Error
1.67e, 1.67000, 1.670, 1.67
1.67e, 1.67, 1.67000, 1.67f
Chọn A
What will be output of program?
LaptrinhC++
abc
Complier error
None of these
Chọn B
What will be output of program?
LaptrinhC++
abc
Complier error
None of these
Chọn A
If the file tobe included does not exist, the preprocessor flashes an error message
True
False
Chọn A
What is output of the program?
100
Garbage value
Error
0
Chọn A
What will happen if in the C program you assign a value to a array element whose subscript exceeds the size of array?
The element will be set to 0.
The complier would report an error.
The program may crash if some important data gets overwritten
The array size would appropriately grow
Chọn C
What is output of the program?
6.000000
6
Error
Chọn A
In which stage the following code. Gets replaced by the contents of the file stdio.h
During editing
During linking
During execution
During preprocessing
Chọn D
What will be output of the program?
8 4 8
4 4 8
4 8 10
4 8 12
Chọn A
A function cannot be defined inside another function
True
False
Chọn A
What is the notation for following functions?
1. KR Notation and 2. ANSI Notation
1. Pre ANSI C Notation and 2. KR Notation
1. ANSI Notation and 2. KR Notation
1. ANSI Notation and 2. Pre ANSI Notation
Chọn C
Name of functions in two different files linked together must be unique.
True
False
Chọn A
If return type for a function is not specified, it defaults to int
True
False
Chọn A
A function may have ant number of return statements each returning different values.
True
False
Chọn A
Functions cannot return more than one value at a time
True
False
Chọn A
Function can be called either by value or reference
True
False
Chọn A
How many times the program will print “laptrinhc++”?
Infinite times
65535 times
Till stack overflows
Cannot call main( ) in main( )
Chọn C
In C all function except main( ) can be called recursively
True
False
Chọn B
Is it true that too many recursive calls may result into stack overflow?
Yes
No
Chọn A







