Figure showing the steps to check if a number is positive, negative or zero in a C program.

See It in Action: Program Output
Let's say you run the program and type in 5 when it asks for a number. Here's what you'd typically see on your screen:

Enter any number: 5 Number 5 is positive.

Diving Deeper: How Each Line Works (The "Aha!" Moments)
Ready to uncover the secrets behind each line? Let's break down this C program piece by piece:

First up, #include <stdio.h>: Think of this as grabbing a toolbox. This specific toolbox (the Standard Input-Output Library) gives your program essential tools like printf() (for showing messages) and scanf() (for reading what you type). Without it, your program would be a bit lost!

Next, int main() { ... }: This is where your program's story begins. When you run your C code, the computer always looks for this main() function first. It's the grand entrance!

Then, int n;: This line is super important! It tells the computer, "Hey, I need a spot in memory to store a whole number and I'm going to call that spot n."

printf("Enter any number: ");: This is your program talking to you! It displays the message "Enter any number: " on your screen, patiently waiting for your input.

scanf("%d", &n);: Now it's the program's turn to listen. This command waits for you to type a whole number and press Enter. Once you do, it carefully places that number right into our n variable. The &n part is just how C knows where to put the number.

if (n > 0) { ... }: This is where the magic of decision making starts! The program asks itself, "Is the value currently stored in n greater than zero?" If the answer is a big YES (meaning n is positive), then the code lines tucked inside these curly braces {} get to run.

else if (n < 0) { ... }: Okay, the program thinks, if n wasn't positive, let's try another check." This line asks, "Is the value in n less than zero?" If this time the answer is YES (meaning n is negative), then the code inside this else if's curly braces runs.

else { ... }: "Well, if n wasn't positive AND it wasn't negative," the program concludes, "there's only one logical possibility left!" The code in this final else block then takes over. This means n must be zero! So, it prints that out.

Finally, return 0;: This is like the program giving a polite nod and saying, "All done here! Everything went smoothly." It tells your computer that the program ran without any issues.

And there you have it! You've successfully built a program that can make smart decisions about numbers. How cool is that for a start?


Other Topic:-->>Nested While Loop.
 -->> NEXT:2. Write a program in C to find the maximum number among given three numbers using nested if else statements only.
-->>ALL Conditionl statements Programs