Question 51
MediumWhat does the 'volatile' qualifier tell a C compiler?
- A.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Programming Languages
What does the 'volatile' qualifier tell a C compiler?
The variable is constant
The variable may change outside the program's control, so every access must really read or write memory
The variable is stored in a register
The variable is thread-safe
Sign up free to see the answer and a step-by-step explanation.
What does a macro like #define SQ(x) x * x give for SQ(2 + 3)?
Compilation error
25
11, because it expands to 2 + 3 * 2 + 3
10
Sign up free to see the answer and a step-by-step explanation.
Which storage class makes a global variable visible only within its own source file?
auto
extern
static
register
Sign up free to see the answer and a step-by-step explanation.
What is the size of a pointer on a typical 64-bit system?
It depends on the type pointed to
2 bytes
8 bytes
4 bytes
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
#include <stdio.h>
#define SQ(x) x * x
int main(void) {
int x = 3;
printf("%d", SQ(x + 2));
return 0;
}
13
25
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
#include <stdio.h>
int main(void) {
int n = printf("hello");
printf(" %d", n);
return 0;
}
hello 6
hello
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
#include <stdio.h>
void swap(int *a, int *b) {
int t = *a;
*a = *b;
*b = t;
}
int main(void) {
int x = 1, y = 2;
swap(&x, &y);
printf("%d %d", x, y);
return 0;
}
2 1
1 2
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
#include <stdio.h>
void swap(int a, int b) {
int t = a;
a = b;
b = t;
}
int main(void) {
int x = 1, y = 2;
swap(x, y);
printf("%d %d", x, y);
return 0;
}
2 1
1 2
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
#include <stdio.h>
struct S {
char a;
int b;
char c;
};
int main(void) {
printf("%zu", sizeof(struct S));
return 0;
}
12
16
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
#include <stdio.h>
int main(void) {
unsigned int u = -1;
printf("%u", u);
return 0;
}
0
4294967295
Sign up free to see the answer and a step-by-step explanation.
9
11
hello 5
5 hello
2 2
1 1
2 2
1 1
9
10
Error
-1