Search⌘ K
AI Features

String or Not?

Discover how to analyze and predict string outputs in C puzzles. This lesson helps you enhance your coding logic and understanding of string operations by examining sample code and discussing its behavior.

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.