Trắc Nghiệm Ngôn Ngữ Lập Trình C ( English ) - Bài 80
1-
A short integer is at least 16 bits wide and a long integer is at least 32 bits wide.
A -
True
B -
False
2-
Which of the following correctly shows the hierarchy of arithmetic operations in C?
A -
/ + * -
B -
* - / +
C -
+ - / *
D -
/ * + -
3-
In which order do the following gets evaluated
1. Relational
2. Arithmetic
3. Logical
4. Assignment
A -
2134
B -
1234
C -
4321
D -
3214
4-
Associativity has no role to play unless the precedence of operator is same.
A -
True
B -
False
5-
If the binary eauivalent of 5.375 in normalised form is 0100 0000 1010 1100 0000 0000 0000 0000, what will be the output of the program (on intel machine)?
#include<stdio.h>
#include<math.h>
int main()
{
float a=5.375;
char *p;
int i;
p = (char*)&a;
for(i=0; i<=3; i++)
printf("%02x\n", (unsigned char)p[i]);
return 0;
}
A -
40 AC 00 00
B -
04 CA 00 00
C -
00 00 AC 40
D -
00 00 CA 04
6-
A float occupies 4 bytes. If the hexadecimal equivalent of these 4 bytes are A, B, C and D, then when this float is stored in memory in which of the following order do these bytes gets stored?
A -
ABCD
B -
DCBA
C -
0xABCD
D -
Depends on big endian or little endian architecture
7-
What will be the output of the program?
#include<stdio.h>
int sumdig(int);
int main()
{
int a, b;
a = sumdig(123);
b = sumdig(123);
printf("%d, %d\n", a, b);
return 0;
}
int sumdig(int n)
{
int s, d;
if(n!=0)
{
d = n%10;
n = n/10;
s = d+sumdig(n);
}
else
return 0;
return s;
}
A -
4, 4
B -
3, 3
C -
6, 6
D -
12, 12
8-
Point out the error in the program
f(int a, int b)
{
int a;
a = 20;
return a;
}
A -
Missing parenthesis in return statement
B -
Redeclaration of a
C -
The function should be defined as int f(int a, int b)