Answers for "c program for positive or negative"

C
0

c program for positive or negative

//Negative or positive
#include <stdio.h>
int main()
{
    int Num;
    printf("Test Data: ");
    scanf("%d", &Num);
    
//A negative number is less than 0, so the if suggests that if the program detects any number less than 0, then it must be a negative    
    if(Num < 0)
    {
        printf("%d is a Negative number", Num);
    }
//Otherwise, the program will consider the number as positive.
    else
    {
        printf("%d is a Positive number", Num);
    }

}
Posted by: Guest on April-19-2021

Code answers related to "c program for positive or negative"

Code answers related to "C"

Browse Popular Code Answers by Language