Black Friday Special Sale - Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: mxmas70

Home > C++ Institute > C++ Institute Certification > CLA-11-03

CLA-11-03 CLA - C Certified Associate Programmer Question and Answers

Question # 4

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

#include

int fun(int i) {

return i++;

}

int main (void) {

int i = 1;

i = fun(i);

printf("%d",i);

return 0;

}

Choose the correct answer:

A.

The program outputs 2

B.

Compilation fails

C.

The program outputs 0

D.

The program outputs 1

E.

The program outputs an unpredictable value

Full Access
Question # 5

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

#include

int main (int argc, char *argv[]) {

char *s = "\\\"\\\\";

printf ("[%c]", s [1]);

return 0;

}

Choose the right answer:

A.

Execution fails

B.

The program outputs ["]

C.

The program outputs []

D.

The program outputs []

E.

Compilation fails

Full Access
Question # 6

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

#include

int main (int argc, char *argv[]) {

char *p = "John" " " "Bean";

printf("[%s]", p) ;

return 0;

}

Choose the right answer:

A.

The program outputs "[]"

B.

The program outputs nothing

C.

The program outputs [John Bean]

D.

The program outputs three lines of text

E.

The program outputs two lines of text

Full Access
Question # 7

What happens when you compile and run the following program?

#include

#define SYM

#define BOL 100

#undef SYM

int main (void) {

#ifdef SYM

int i = 100;

#else

int i= 200;

#endif

int j = i + 200;

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

return 0;

}

Select the correct answer:

A.

The program outputs 200

B.

The program outputs 100

C.

The program outputs 400

D.

The program outputs 300

E.

The program outputs 600

Full Access
Question # 8

Assume that ints are 32-bit wide.

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

#include

typedef union {

int i;

int j;

int k;

} uni;

int main (int argc, char *argv[]) {

uni s;

s.i = 3;

s.j = 2;

s.k = 1;

printf("%d",s.k * (s.i - s.j));

return 0;

}

Choose the right answer:

A.

The program outputs 9

B.

The program outputs 0

C.

Execution fails

D.

Compilation fails

E.

The program outputs 3

Full Access
Question # 9

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

#include

int main(int argc, char *argv[]) {

int i = 2 / 1 + 4 / 2;

printf("%d",i);

return 0;

}

Choose the right answer:

A.

The program outputs 5

B.

Compilation fails

C.

The program outputs 3

D.

The program outputs 0

E.

The program outputs 4

Full Access
Question # 10

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

#include

#include

struct STR {

int i;

char c[20];

float f;

};

int main (int argc, char *argv[]) {

struct STR str = { 1, "Hello", 3 };

printf("%d", str.i + strlen(str.c));

return 0;

}

Choose the right answer:

A.

The program outputs 4

B.

The program outputs 1

C.

The program outputs 5

D.

The program outputs 6

E.

Compilation fails

Full Access
Question # 11

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

#include

int *fun(int *t) {

return t + 4;

}

int main (void) {

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

int *ptr;

ptr = fun (arr - 3);

printf("%d \n", ptr[2]);

return 0;

}

Choose the right answer:

A.

The program outputs 2

B.

The program outputs 4

C.

The program outputs 5

D.

The program outputs 1

E.

The program outputs 3

Full Access
Question # 12

Assume that ints are 32-bit wide.

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

#include

typedef struct

int i;

int j;

int k;

} str;

int main (int argc, char *argv[]) {

str s = { 7, 7, 7 };

printf ("%d", sizeof (s.s));

return 0;

}

Choose the right answer:

A.

Execution fails

B.

The program outputs 16

C.

Compilation fails

D.

The program outputs 12

E.

The program outputs 4

Full Access