Search⌘ K
AI Features

It Just Can’t Be Done

Discover how to analyze C code puzzles to predict their output. This lesson helps you develop your ability to understand programming logic, debug code, and prepare for more complex C challenges through active coding exercises.

We'll cover the following...

Puzzle code

Read carefully the code given below:

C
#include <stdio.h>
int main()
{
char a;
for( a=0; a<200; a++ )
printf("%3d ", a);
putchar('\n');
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.

The program will print the numbers 0 to 199, each formatted to three spaces.

B.

The program will print the numbers 0 to 255, each formatted to three spaces.

C.

The program will print the numbers 0 to 127, each formatted to three spaces, followed by a newline.

D.

The program will enter an infinite loop, cycling from 0 to 127, then from -128 to 0 again.


1 / 1

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