Which of the following strings is a proper integer number (in the C language sense)?
Select correct answer (single choice)
123,456
123_456
123456
123.456
What is the value of the following integer literal?
08
Select correct answer (single choice)
1000
10
the literal is invalid
What is the value of the following integer literal?
0x8
Select correct answer (single choice)
the literal is invalid
10
1000
Which of the following strings is a valid variable name?
Select correct answer (single choice)
Monte-Carlo
Monte Carlo
Monte_Carlo
Monte@Carlo
Which of the following strings is an invalid variable name?
Select correct answer (single choice)
_0
0_
___
_0_
Is the following declaration valid?
int var, var;
Select correct answer (single choice)
Yes
No
What is the value of the var variable at the end of the following snippet?
int var;
var = 2;
var = var * var;
var = var + var;
var = var / var;
var = var var;
Select correct answer (single choice)
16
What is the value of the var variable at the end of the following snippet?
int var;
var = 2;
var = var * var;
var = var + var;
/*
var = var / var;
var = var var;
*/
Select correct answer (single choice)
16
Which of the following strings is a proper floating-point number (in the C language sense)?
Select correct answer (single choice)
123,456
123.456
123_456
123456
What is the value of the following floating-point literal?
8765E-2
Select correct answer (single choice)
876.5
0.8765
8.765
87.65
What is the value of the x variable at the end of the following snippet?
int x;
x = 1 / 2;
Select correct answer (single choice)
0.5
What is the value of the x variable at the end of the following snippet?
int x;
x = 1 / 2 * 3;
/***
Select correct answer (single choice)
1.5
What is the value of the x variable at the end of the following snippet?
float x;
x = 1. / 2 * 3;
/***
Select correct answer (single choice)
1.5
What is the value of the k variable at the end of the following snippet?
int i,j,k;
i = 4;
j = 5;
k = --i * j++;
Select correct answer (single choice)
16
15
12
18
What is the value of the k variable at the end of the following snippet?
int i,j,k;
i = 4;
j = 5;
k = i-- * ++j;
Select correct answer (single choice)
21
24
18
28
What is the value of the k variable at the end of the following snippet?
int i,j,k;
i = 3;
j = -3;
k = i * j;
k += j;
k /= i;
Select correct answer (single choice)
-8
-4
What is the value of the c variable at the end of the following snippet?
char c;
c = '\';
Select correct answer (single choice)
the assignment is invalid and causes a compilation error
\0
'
What is the value of the c variable at the end of the following snippet?
char c;
c = 'a';
c -= ' ';
Select correct answer (single choice)
the assignment is invalid and causes a compilation error
\0
What is the value of the k variable at the end of the following snippet?
int i,j,k;
i = 3;
j = -3;
k = (i >= i) + (j <= j) + (i == j) + (i > j);
Select correct answer (single choice)
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int i,j,k;
i = 2;
j = -2;
if(i)
i--;
if(j)
j++;
k = i * j;
printf("%d",k);
return 0;
}
Select correct answer (single choice)
the program outputs -2
the program outputs -1
the program outputs 2
the program outputs 1
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int i, j, k;
i = -1;
j = 1;
if(i)
j--;
if(j)
i++;
k = i * j;
printf("%d",k);
return 0;
}
Select correct answer (single choice)
the program outputs -1
the program outputs 0
the program outputs 2
the program outputs 1
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int i, j, k;
i = 0;
j = 0;
if(j)
j--;
else
i++;
if(i)
i--;
else
j++;
k = i + j;
printf("%d",k);
return 0;
}
Select correct answer (single choice)
the program outputs 2
the program outputs -1
the program outputs 0
the program outputs 1
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int i, j, k;
i = 2;
j = 3;
if(j)
j--;
else if(i)
i++;
else
j++;
if(j)
i--;
else if(j)
j++;
else
j = 0;
k = i + j;
printf("%d",k);
return 0;
}
Select correct answer (single choice)
the program outputs 2
the program outputs 3
the program outputs 0
the program outputs 1
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
double x = -.1;
int i = x;
printf("%d",i);
return 0;
}
Select correct answer (single choice)
the program outputs 0
the program outputs -0.100000
the program outputs 0.100000
the program outputs -1
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
float x,y;
int i,j;
x = 1.5; y = 2.0;
i = 2; j = 3;
x = x * y + i / j;
printf("%f",x);
return 0;
}
Select correct answer (single choice)
the program outputs 0.000000
the program outputs 3.000000
the program outputs 2.000000
the program outputs 1.000000
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
float x,y;
int i,j;
x = 1.5; y = 2.0;
i = 2; j = 4;
x = x * y + (float)i / j;
printf("%f",x);
return 0;
}
Select correct answer (single choice)
the program outputs 3.500000
the program outputs 3.000000
the program outputs 4.000000
the program outputs 2.000000
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int i;
i = 1;
while(i < 16)
i *= 2;
printf("%d",i);
return 0;
}
Select correct answer (single choice)
the program outputs 4
the program outputs 8
the program outputs 16
the program outputs 32
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int i, j;
i = 1; j = 1;
while(i < 16) {
i += 4;
j++;
}
printf("%d",j);
return 0;
}
Select correct answer (single choice)
the program outputs 7
the program outputs 6
the program outputs 5
the program outputs 4
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int i = 7, j = i - i;
while(i) {
i /= 2;
j++;
}
printf("%d",j);
return 0;
}
Select correct answer (single choice)
the program outputs 1
the program outputs 2
the program outputs 0
the program outputs 3
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int i = 7, j = i - i;
while(!i) {
i /= 2;
j++;
}
printf("%d",j);
return 0;
}
Select correct answer (single choice)
the program outputs 2
the program outputs 1
the program outputs 3
the program outputs 0
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int i, j = 1;
for(i = 11; i > 0; i /= 3)
j++;
printf("%d",j);
return 0;
}
Select correct answer (single choice)
the program outputs 5
the program outputs 2
the program outputs 3
the program outputs 4
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int i, j = 0;
for(i = 0; !i ; i++)
j++;
printf("%d",j);
return 0;
}
Select correct answer (single choice)
the program outputs 1
the program outputs 2
the program outputs 0
the program outputs 3
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int i = 1, j = -2;
for(;;) {
i *= 3;
j++;
if(i > 30)
break;
}
printf("%d",j);
return 0;
}
Select correct answer (single choice)
the program outputs 3
the program outputs 1
the program outputs 2
the program outputs 0
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int i = 1, j = -2, k;
k = (i >= 0) && (j >= 00) || (i <= 0) && (j <= 0);
printf("%d",k);
return 0;
}
Select correct answer (single choice)
the program outputs 0
the program outputs 3
the program outputs 2
the program outputs 1
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int i = 1, j = -2, k;
k = (i >= 0) || (j >= 00) && (i <= 0) || (j <= 0);
printf("%d",k);
return 0;
}
Select correct answer (single choice)
the program outputs 3
the program outputs 0
the program outputs 1
the program outputs 2
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int i = 1, j = -2, k;
k = !(i >= 0) || !(j >= 00) && !(i <= 0) || !(j <= 0);
printf("%d",k);
return 0;
}
Select correct answer (single choice)
the program outputs 1
the program outputs 0
the program outputs 3
the program outputs 2
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int i = 1, j = 0, k;
k = i & j;
k |= !!k;
printf("%d",k);
return 0;
}
Select correct answer (single choice)
the program outputs 1
the program outputs 0
the program outputs 3
the program outputs 2
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int i = 1, j = 0, k;
k = !i | j;
k = !k;
printf("%d",k);
return 0;
}
Select correct answer (single choice)
the program outputs 2
the program outputs 1
the program outputs 0
the program outputs 3
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int i = 1, j = 0, k;
k = (i ^ j) + (!i ^ j) + (i ^ !j) + (!i ^ !j);
printf("%d",k);
return 0;
}
Select correct answer (single choice)
the program outputs 2
the program outputs 0
the program outputs 3
the program outputs 1
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int i = 0, j = 1, k;
k = i << j + j << i;
printf("%d",k);
return 0;
}
Select correct answer (single choice)
the program outputs 1
the program outputs 2
the program outputs 0
the program outputs 3
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int i = 3, j = i - 2;
switch(i - 2) {
case 1: j++;
case 2: j++;
case 0: j++; break;
default:j = 0;
}
printf("%d",j);
return 0;
}
Select correct answer (single choice)
the program outputs 1
the program outputs 3
the program outputs 2
the program outputs 4
What happens if you try to compile and run this program?
#include <stdio.h>
#include <stdio.h>
int main(void) {
int i = 3, j = i - 2;
switch(i + 2) {
case 1: j++;
case 2: j++;
default:j = 0;
case 0: j++; break;
}
printf("%d",j);
return 0;
}
Select correct answer (single choice)
the program outputs 1
the program outputs 3
the program outputs 4
the program outputs 2
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int i, t[5];
t[0] = 0;
for(i = 1; i < 5; i++)
t[i] = t[i - 1] + i;
printf("%d",t[4]);
return 0;
}
Select correct answer (single choice)
the program outputs 10
the program outputs 9
the program outputs 8
the program outputs 11
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int i, t[5];
t[4] = 0;
for(i = 3; i >= 0; i--)
t[i] = t[4] * i;
printf("%d",t[0]);
return 0;
}
Select correct answer (single choice)
the program outputs 0
the program outputs 1
the program outputs 2
the program outputs -1
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int t[2];
t[0] = 1; t[1] = 0;
printf("%d",t[t[t[t[t[0]]]]]);
return 0;
}
Select correct answer (single choice)
the program outputs 1
the program outputs 0
the program outputs 2
the program outputs -1
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int i,t[3];
for(i = 2; i >=0 ; i--)
t[i] = i - 1;
printf("%d",t[1] - t[t[0] + t[2]]);
return 0;
}
Select correct answer (single choice)
the program outputs 2
the program outputs 0
the program outputs -1
the program outputs 1
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int i,t[4] = { 1, 2, 4, 8 };
for(i = 0; i < 2 ; i++)
t[i] = t[3 - i];
printf("%d",t[2]);
return 0;
}
Select correct answer (single choice)
the program outputs 8
the program outputs 4
the program outputs 1
the program outputs 2
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int s,i,t[] = { 0, 1, 2, 3, 4, 5 };
s = 1;
for(i = 2; i < 6 ; i += i + 1)
s += t[i];
printf("%d",s);
return 0;
}
Select correct answer (single choice)
the program outputs 1
the program outputs 8
the program outputs 2
the program outputs 4
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
char t[] = { 'a', 'b', 'A', 'B' };
printf("%d",t[1] - t[0] + t[3] - t[2]);
return 0;
}
Select correct answer (single choice)
the program outputs 1
the program outputs 8
the program outputs 2
the program outputs 4
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
float t[5] = { 1E0, 1E1, 1E2, 1E3, 1E4 };
printf("%f",t[0] + t[2] + t[3]);
return 0;
}
Select correct answer (single choice)
the program outputs 1011.000000
the program outputs 1110.000000
the program outputs 1101.000000
the program outputs 1111.000000
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int i = 1, *j = &i, **k = &j;
printf("%d",**k);
return 0;
}
Select correct answer (single choice)
the program outputs 1
the program outputs nul
the program outputs NULL
the program outputs 0
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
char t[3];
printf("%d",sizeof(t) - sizeof(t[0]));
return 0;
}
Select correct answer (single choice)
the program outputs 4
the program outputs 2
the program outputs 1
the program outputs 3
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int t[6];
printf("%d",sizeof(t) / sizeof(int));
return 0;
}
Select correct answer (single choice)
the program outputs 4
the program outputs 2
the program outputs 8
the program outputs 6
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int t[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, *p = t + 4;
p += *p;
printf("%d",*p);
return 0;
}
Select correct answer (single choice)
the program outputs 7
the program outputs 8
the program outputs 10
the program outputs 9
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
int t[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, *p = t;
p += 2;
p += p[-1];
printf("%d",*p);
return 0;
}
Select correct answer (single choice)
the program outputs 7
the program outputs 5
the program outputs 1
the program outputs 3
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
char s[] = "\0\1\2\3\4";
printf("%c",'A' + s[3]);
return 0;
}
Select correct answer (single choice)
the program outputs B
the program outputs D
the program outputs C
the program outputs A
What happens if you try to compile and run this program?
#include <stdio.h>
int main(void) {
printf("%c","ACEGIK"[3] - 1);
return 0;
}
Select correct answer (single choice)
the program outputs E
the program outputs G
the program outputs F
the program outputs H
What happens if you try to compile and run this program?
#include <stdio.h>
#include <string.h>
int main(void) {
char s[10] = "ABCDE";
strcpy(s + 2, "ABCDE");
printf("%d", s[0] - s[2]);
return 0;
}
Select correct answer (single choice)
the program outputs -1
the program outputs 0
the program outputs 1
the program outputs -2
What happens if you try to compile and run this program?
#include <stdio.h>
#include <string.h>
int main(void) {
char s[11] = "CABDE";
strcat(s + 2, "CABDE");
printf("%d", s[0] - s[2]);
return 0;
}
Select correct answer (single choice)
the program outputs -2
the program outputs -1
the program outputs 0
the program outputs 1
What happens if you try to compile and run this program?
#include <stdio.h>
#include <string.h>
int main(void) {
char s[11] = "ABCDE";
strcat(s + 2, "ABCDE");
printf("%d", s[0] - s[2]);
return 0;
}
Select correct answer (single choice)
the program outputs -2
the program outputs 1
the program outputs -1
the program outputs 0