The screen glowed in the quiet computer lab.
Pran stared at the message that had just appeared.
NEXT TASK: SECURITY CHECK
ENTER PASSWORD:
The cursor blinked.
Patiently.
_
Pran leaned back in his chair.
"A password, huh?"
He tapped the keyboard randomly.
pizza
Nothing happened.
The cursor blinked again.
Still waiting.
"Okay," Pran said. "Clearly the computer doesn't know what to do with that."
Of course it didn't.
He hadn't written any code to check passwords yet.
Right now the computer could:
• print text• ask questions• store answers
But it couldn't make decisions.
And decisions are extremely important.
Imagine a computer that couldn't decide anything.
For example:
A login system that says:
"Welcome!" to everyone.
Even hackers.
Even aliens.
Even someone typing:
banana
That would be a very bad security system.
Computers need logic.
They need rules.
They need something like:
IF this happens → do thisOTHERWISE → do something else
And that is exactly what the if statement does.
Pran opened the program again.
He started typing.
#include
int main() {
int password;
printf("Enter password:\n");
scanf("%d", &password);
if(password == 1234) {
printf("Access granted\n");
}
return 0;
}
He stared at the screen.
"This is interesting."
Let's break it down.
First we created a variable.
int password;
This variable stores a number.
Then we ask the user to enter the password.
scanf("%d", &password);
Now comes the important part.
if(password == 1234)
This line means:
If the password equals 1234, then run the code below.
Notice the double equals sign.
==
This means compare.
It does not mean assignment.
This is one of the most common beginner mistakes.
For example:
Wrong:
if(password = 1234)
Correct:
if(password == 1234)
One = means store a value.
Two == means compare values.
Programmers mix these up all the time.
Even experienced ones.
Now look at the braces.
{
}
Everything inside the braces happens only if the condition is true.
So this code:
if(password == 1234) {
printf("Access granted\n");
}
means:
If the password is 1234 → print Access granted.
Pran ran the program.
The screen displayed:
Enter password:
He typed:
1234
The computer responded:
Access granted
Pran nodded.
"Nice."
But he noticed something.
What happens if the password is wrong?
He ran the program again.
Enter password:
He typed:
1111
Nothing happened.
The program simply ended.
"That's awkward," Pran said.
If a password is wrong, the computer should say something like:
"Access denied."
This is where else comes in.
else means:
If the previous condition was false, do this instead.
Pran updated the code.
#include
int main() {
int password;
printf("Enter password:\n");
scanf("%d", &password);
if(password == 1234) {
printf("Access granted\n");
}
else {
printf("Access denied\n");
}
return 0;
}
He ran it again.
The screen displayed:
Enter password:
Pran typed:
9999
The computer responded:
Access denied
Pran smiled.
"That's much better."
Now the program could make decisions.
He imagined the computer as a security guard.
Guard logic:
If password correct → open door
Else → deny entry
The computer lab suddenly felt quieter.
The screen flickered again.
Then something strange happened.
The text on the screen changed.
A new message appeared.
SECURITY SYSTEM CONNECTED
Pran frowned.
"That definitely wasn't my code."
Another line appeared.
TEST PASSWORD REQUIRED
Then a blinking cursor appeared again.
ENTER PASSWORD:
Pran typed carefully.
1234
The screen paused.
Then suddenly:
ACCESS GRANTED
The screen flashed.
And something incredible happened.
A simple drawing appeared.
[ SECURITY DOOR OPENED ]
Pran blinked.
"Did I just unlock something?"
The computer printed another message.
SYSTEM AREA 1 UNLOCKED
Then another message appeared.
NEXT MODULE: COUNTING SYSTEM
Pran leaned forward.
"Counting system?"
The cursor blinked again.
_
Waiting.
Silent.
As if the computer was challenging him.
Pran smiled.
"If we're going to count things…"
"We're going to need loops."
Chapter 5 — The Counting Robot (Preview)
This chapter introduces something programmers use all the time.
You will learn:
for loops
repeating actions
counting with code
