109k views
1 vote
Examine the following code. What will be the output from the “printf()” statement below?

#define S_SIZE 10

char s[10] = { ‘g’ , ’o’ , ’m’ , ’i’ , ’z’ , ’z’ , ’o’ , ’u’ };

int j = 0;

for (j = S_SIZE -2; j > 4; j--) { printf( “%c”, s[j]); }

Using the definitions below (IGNORE ALL COMPILE ERRORS):
char s1 [ 50 ] = “JACK”, s2 [ 50 ]=”FRED”;

1 Answer

2 votes

Answer:

uoz (with one space on the left most side)

Step-by-step explanation:

#define is used to define macros, it just substitutes the value in the program.

For example:

#define S_SIZE 10

so, it put the value 10 where we write 'S_SIZE'.

then, character array define which has 8 elements.

Note: Array index starts from 0.

the, for loop is execute from 8 to j > 4( means 5).

it prints s[8] which not present in the array so, it prints blank space.

s[7] it prints 'u'

s[6] it prints 'o'

s[5] it prints 'z'

then the loop will be terminated.

Therefore, the answer is uoz with space on the leftmost side.

User ToNoY
by
5.7k points