String or Not?

Test your C programming skills by solving the given puzzle about character arrays and their output.

We'll cover the following...

Puzzle code

Read carefully the code given below:

C
#include <stdio.h>
int main()
{
char nonstring[] = {
'g', 'r', 'e', 'e', 't',
'i', 'n', 'g', 's', ',', ' ', 'h', 'u', 'm', 'a', 'n'
};
char data[] = { 127, 129, 255 };
printf("%s\n", nonstring);
return(0);
}

Your task: Guess the output

Attempt the following test to assess your understanding.

Technical Quiz
1.

What is the expected output of the above code?

A.

greetings, human0?u??

B.

greetings, human followed by garbage values

C.

greetings, human

D.

The code will not compile due to an error.


1 / 1

Let's discuss the code and output together in the next lesson.