Você está na página 1de 25

What is the value of the following integer literal?

017

Select correct answer (single choice)

17

23

the literal is invalid

15

What is the value of the following integer literal?

0x17

Select correct answer (single choice)

the literal is invalid

23

17

15

Which of the following strings is a valid variable name?

Select correct answer (single choice)

anti_world

none of these

anti-world
anti:world

Which of the following declarations is valid?

Select correct answer (single choice)

float floating;

float float;

float long;

float int;

What is the value of the X variable at the end of the following snippet?

int X = 8;

X = X - X / 2;

X = X * X / 4;

X = X + 2 * X;

Select correct answer (single choice)

10

14

16

12

What is the value of the X variable at the end of the following snippet?

float X = 2.0;

X = X + X * 4;

X = X / X * X;

X = X / X + X;
Select correct answer (single choice)

11.000000

1.000000

0.500000

110.000000

Which of the following strings is a proper floating-point number (in the "C"
language sense)?

Select correct answer (single choice)

3,0x10^8

3E8

300,000,000

3.0x10^8

What is the value of the Z variable at the end of the following snippet?

int X = 1;

int Y = X + 2;

Y++;

int Z = Y;

--X;

Y--;

Z = X / Y * X * Y;

Select correct answer (single choice)


3

What is the value of the X variable at the end of the following snippet?

int X;

X = ('r' - 's') * ('A' / 'Z');

Select correct answer (single choice)

the snippet is invalid and will cause compilation error

What happens if you try to compile and run this program?

#include <stdio.h>

int main(void) {

int x = 1, y = 1;

float k = -1e0, m = 2e1;

printf("%d\n", (x >= y) + (x >= y) + (k >= y) + (m >= k) + ('q' <= 'z'));

return 0;

Select correct answer (single choice)


the program outputs 2

the program outputs 3

the program outputs 4

the program outputs 1

What happens if you try to compile and run this program?

#include <stdio.h>

int main(void) {

int i = 1;

if(i = 0)

i = 2;

else

i = 3;

printf("%d\n",i);

return 0;

Select correct answer (single choice)

the program outputs 4

the program outputs 3

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 = 0;

do {

i *= 2;

j += i / 2;

} while(j < 1);

printf("%d",i + j);

return 0;

Select correct answer (single choice)

the program enters an infinite loop and outputs nothing

the program outputs 2

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 = 5, j = 16;

while(j >= 0) {

i /= 2;

j -= i / 2;

printf("%d",i + j);

return 0;

}
Select correct answer (single choice)

the program outputs 3

the program outputs 1

the program outputs 2

the program enters an infinite loop and outputs nothing

What happens if you try to compile and run this program?

#include <stdio.h>

int main(void) {

int i = 1, j;

for(j = 0; j ; j--)

i *= 2;

printf("%d",i + j);

return 0;

Select correct answer (single choice)

the program outputs 2

the program outputs 1

the program outputs 3

the program enters an infinite loop and outputs nothing

What happens if you try to compile and run this program?

#include <stdio.h>

int main(void) {
int i = -1, j = 1;

for(i++; i++; i++)

j++;

printf("%d",i + j);

return 0;

Select correct answer (single choice)

the program enters an infinite loop and outputs nothing

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 i = 1, j = 0, k;

k = (i >> j) + (j >> i) + (i >> i) + (j >> j);

k <<= i;

printf("%d", k);

return 0;

Select correct answer (single choice)

the program outputs 4

the program outputs 1


the program outputs 0

the program outputs 2

What happens if you try to compile and run this program?

#include <stdio.h>

int main(void) {

int i = 3, j = i - 2 * i;

switch(i - j) {

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 4

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 = 5, j = i - 4 * i;

switch(j) {

default: j = 2;

case 1: j--; break;

case 2: j++;

case 0: j--; break;

printf("%d", j++);

return 0;

Select correct answer (single choice)

the program outputs 1

the program outputs 4

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, t[4];

for(i = 0; i < 3; i++) {

t[i] = 4 - i;

t[i + 1] = 2 * t[i];

printf("%d\n", t[2]);
return 0;

Select correct answer (single choice)

the program outputs 4

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, s = 0, t[] = {16, 8, 4, 2, 1, 0};

for(i = 5; t[i] > 2; i /= 2)

s += t[i];

printf("%d\n", s);

return 0;

Select correct answer (single choice)

the program outputs 2

the program outputs 4

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) {

char t[] = { 'x', 'z', 'Y', 'Z', '2' , '0'};

printf("%d\n", t[t[1] - t[0] - t[3] + t[2] + 3] - t[5]);

return 0;

Select correct answer (single choice)

the program outputs 0

the program outputs 2

the program outputs 4

the program outputs 1

What happens if you try to compile and run this program?

#include <stdio.h>

int main(void) {

float a = 3.14E0, *b = &a, **c = &b;

**c = a + (a == *b);

printf("%f", a);

return 0;

Select correct answer (single choice)

the program outputs 2.140000

the program outputs 4.140000

the program outputs NULL


the program outputs 3.140000

What happens if you try to compile and run this program?

#include <stdio.h>

int main(void) {

char t[4][4];

printf("%d\n",sizeof(t) / sizeof(t[0]) / sizeof(t[0][0]));

return 0;

Select correct answer (single choice)

the program outputs 4

the program outputs 1

the program outputs 8

the program outputs 2

What happens if you try to compile and run this program?

#include <stdio.h>

int main(void) {

char *p = "\0\2\1\3\4";

printf("%d\n", p[p[2]] + *(p + 1) + p[0]);

return 0;

Select correct answer (single choice)

the program outputs 2


the program outputs 8

the program outputs 1

the program outputs 4

What happens if you try to compile and run this program?

#include <stdio.h>

#include <string.h>

int main(void) {

char tt[20] = "9081726354";

strcpy(tt, tt + 3);

printf("%d\n", strlen(tt) - tt[9] + '5');

return 0;

Select correct answer (single choice)

the program outputs 2

the program outputs 1

the program outputs 4

the program outputs 8

What happens if you try to compile and run this program?

#include <stdio.h>

#include <string.h>

int main(void) {

char tt[20] = "0123456789";

strcat(tt + 11, "123");


printf("%d\n", strlen(tt) - tt[8] + '0');

return 0;

Select correct answer (single choice)

the program outputs 1

the program outputs 4

the program outputs 8

the program outputs 2

What happens if you try to compile and run this program?

#include <stdio.h>

#include <stdlib.h>

int main(void) {

float *t = 1 + (float *) malloc(sizeof(float) * sizeof(float));

t--;

*t = 8.0;

t[1] = *t / 4.0;

t++;

t[-1] = *t / 2.0;

printf("%f\n",*t);

free(--t);

return 0;

Select correct answer (single choice)


the program outputs 4.000000

the program outputs 8.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>

#include <string.h>

struct S {

char S[8];

};

int main(void) {

struct S S = { 'a', 'b', 'c', 'd' };

printf("%d", sizeof(S.S) - strlen(S.S) + S.S[4]);

return 0;

Select correct answer (single choice)

the program outputs 2

the program outputs 1

the program outputs 8

the program outputs 4

What happens if you try to compile and run this program?

#include <stdio.h>
#include <string.h>

#include <stdlib.h>

struct S {

char *S;

};

int main(void) {

struct S *S = (struct S *) malloc(sizeof(struct S));

S -> S = "123\0""45678";

printf("%d", strlen(S -> S + 5) + S -> S[3]);

free(S);

return 0;

Select correct answer (single choice)

the program outputs 2

the program outputs 1

the program outputs 4

the program outputs 8

What happens if you try to compile and run this program?

#include <stdio.h>

struct S {

int Var;

struct S *Str;

};
int main(void) {

struct S S[] = { { 8, NULL }, { 4, &S[0] }, { 2, &S[1] } };

printf("%d", S[2].Str->Str->Var);

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 fun(int *t) {

return *(t + 3);

int main(void) {

int arr[] = { 3, 2, 1, 0 };

printf("%d\n", fun(arr - 2));

return 0;

Select correct answer (single choice)

the program outputs 1

the program outputs 4


the program outputs 8

the program outputs 2

What happens if you try to compile and run this program?

#include <stdio.h>

float f(float v) {

v = v / 2.0;

return v + v;

int main(void) {

float x = 4;

f(x);

printf("%f",x);

return 0;

Select correct answer (single choice)

the program outputs 2.000000

the program outputs 8.000000

the program outputs 4.000000

the program outputs 1.000000

What happens if you try to compile and run this program?

#include <stdio.h>

char *f(char *p) {

return p += 2;
}

char *g(char *p) {

return --p;

int main(void) {

char *s = "ABCDEFGHIJ";

char p = *f(g(f(s + 1)));

printf("%d",p - 'A');

return 0;

Select correct answer (single choice)

the program outputs 4

the program outputs 2

the program outputs 1

the program outputs 8

What happens if you try to compile and run this program?

#include <stdio.h>

struct S {

int S[3];

};

void f(struct S S) {

S.S[0] = S.S[1] + S.S[2] - 4;

int main(void) {
struct S S = { { 1, 4, 2 } };

f(S);

printf("%d",S.S[1] * S.S[0]);

return 0;

Select correct answer (single choice)

the program outputs 1

the program outputs 2

the program outputs 4

the program outputs 8

What happens if you try to compile and run this program?

#include <stdio.h>

struct S {

int S[3];

};

void f(struct S *S) {

S->S[2] = 6 * S->S[0] + S -> S[1];

int main(void) {

struct S S = { { 1, 2 } }, *P = &S;

f(P);

printf("%d",S.S[2] / S.S[0]);

return 0;

}
Select correct answer (single choice)

the program outputs 8

the program outputs 2

the program outputs 4

the program outputs 1

What happens if you try to compile and run this program?

#include <stdio.h>

#include <string.h>

char *f(int p, char *s) {

s[p + 2] = '\0';

return s - 1;

int main(void) {

char s[] = "ABCDEF";

int i = strlen(f(1,s + 2));

printf("%d\n",i);

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) {

char s[20] = "?";

FILE *f = fopen("fopen","w");

int i = fputs("789",f);

fclose(f);

f = fopen("fopen","r");

fgets(s + 1,3,f);

printf("%c\n", s[2] - s[3]);

fclose(f);

return 0;

Select correct answer (single choice)

the program outputs 2

the program outputs 4

the program outputs 8

the program outputs 1

What happens if you try to compile and run this program?

#include <stdio.h>

#define ONE 1

#define TWO ONE + ONE

int main(void) {
int i = 2;

i = i - 2 * TWO;

printf("%d\n", i);

return 0;

Select correct answer (single choice)

the program outputs 0

the program outputs 4

the program outputs 2

the program outputs 1

What is the meaning of the following declaration?

float *f(int);

Choose the right answers:

Select correct answer (single choice)

the declaration is erronous

f is a pointer to function (int) returning float;

f is a pointer to function (float) returning int;

f is a function (int) returning pointer to float;

Select the proper form for the following declaration:

ptr is a pointer to pointer to pointer to double

Choose the right answers:

Select correct answer (single choice)


double **ptr;

double *ptr;

the declaration is invalid and cannot be coded in C

double

Você também pode gostar