0% found this document useful (0 votes)
13 views1 page

CPPPRG 5

This document contains a C program that checks if a user-inputted number is positive, negative, or zero. It utilizes conditional statements to determine the number's classification and prints the appropriate message. The program prompts the user for input and processes it accordingly.

Uploaded by

Netra Yardoni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views1 page

CPPPRG 5

This document contains a C program that checks if a user-inputted number is positive, negative, or zero. It utilizes conditional statements to determine the number's classification and prints the appropriate message. The program prompts the user for input and processes it accordingly.

Uploaded by

Netra Yardoni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Check If a Number is Positive, Negative, or Zero

#include <stdio.h>
int main() {
int number;
printf("Enter a number: ");
scanf("%d", &number);

if (number > 0) { // Outer condition


printf("The number is positive.\n");
} else { // Outer else
if (number == 0) { // Inner condition
printf("The number is zero.\n");
} else {
printf("The number is negative.\n");
}
}

return 0;
}

You might also like