LightReader

Chapter 10 - Chapter 10 — The Final Program for C

The computer screen glowed brighter than before.

The robot stood at the center of the display.

[^_^]

/| |\

/ \

Below it, a message slowly appeared.

SYSTEM PROGRESS: 95%

FINAL MODULE DETECTED

FINAL CHALLENGE INITIATED

Pran leaned forward.

"So this is it."

The cursor blinked again.

_

Then the computer displayed another message.

YOU HAVE LEARNED THE CORE SYSTEMS

PRINTING

INPUT

CONDITIONS

LOOPS

FUNCTIONS

POINTERS

ARRAYS

Another line appeared.

NOW BUILD A COMPLETE PROGRAM

Pran smiled.

"This computer really turned learning programming into a game."

He thought about everything he had learned.

A real program needs several things:

• input from the user• some logic• loops to keep the program running• functions to organize code

Pran decided to build something simple but useful.

A number guessing game.

The computer would secretly choose a number.

The user would try to guess it.

The program would keep asking until the correct number was entered.

He began typing.

#include

int main() {

int secret = 7;

int guess = 0;

printf("Welcome to the guessing game!\n");

while(guess != secret) {

printf("Enter your guess: ");

scanf("%d", &guess);

if(guess == secret) {

printf("Correct! You win!\n");

}

else {

printf("Wrong guess. Try again.\n");

}

}

return 0;

}

Pran looked at the program.

"This actually uses a lot of things we learned."

Let's break it down.

First, the program creates two variables.

secret

guess

The secret number is 7.

The user must guess it.

Next, the program prints a welcome message.

Welcome to the guessing game!

Then comes the important part.

while(guess != secret)

This means:

Continue the game until the guess equals the secret number.

Inside the loop, the program asks the user for input.

scanf("%d", &guess);

Then it checks the answer using an if statement.

If the guess is correct:

Correct! You win!

Otherwise:

Wrong guess. Try again.

Pran ran the program.

The computer displayed:

Welcome to the guessing game!

Enter your guess:

Pran typed:

3

The computer responded.

Wrong guess. Try again.

The program asked again.

Enter your guess:

He typed:

5

Still wrong.

The computer responded.

Wrong guess. Try again.

Finally he typed:

7

The program printed:

Correct! You win!

Suddenly the entire screen flashed.

The robot jumped excitedly.

[^O^]

/| |\

/ \

Then a system message appeared.

PROGRAM VERIFIED

Another message appeared.

ALL CORE SYSTEMS UNLOCKED

Pran leaned back in his chair.

"Did I just finish the system?"

The screen flickered again.

Then the computer printed one final message.

CONGRATULATIONS PROGRAMMER

Pran blinked.

"Programmer?"

Another line appeared.

YOU HAVE LEARNED THE FUNDAMENTALS OF C

Then another.

THIS WAS ONLY THE BEGINNING

The cursor blinked one last time.

_

Pran smiled.

He looked at the keyboard.

At the screen.

At the strange robot.

And he realized something important.

Programming wasn't about memorizing complicated code.

It was about thinking step by step.

Breaking problems into small pieces.

And teaching the computer how to solve them.

The robot waved.

[^_^]/

/| |\

/ \

Then the computer printed one last message.

END OF TRAINING MODULE

The screen slowly faded to black.

But before shutting down, a final message appeared.

NEXT STAGE AVAILABLE

ADVANCED PROGRAMS READY

Pran cracked his knuckles.

"Well," he said.

"Let's keep going."

Because this was only the beginning of his programming journey.

End of Book Part 1

The C Programming Adventure

You have now learned the core foundations of C programming:

• printing output• user input• variables• conditions• loops• functions• pointers• arrays

These concepts form the foundation of almost all programming languages.

But programming becomes even more powerful when we begin building real applications.

So in the next part, we will transition to building a completely different program — one that uses these concepts to create something more practical and interactive.

Your journey as a programmer has only just begun. 🚀

More Chapters