Check Whether a number is positive , negative or zero in C program

//Positive , Negative or Zero

#include <stdio.h>
int main()
{
double number;

printf("Enter a number: ");
scanf("%lf", &number);

if (number <= 0.0)
{
if (number == 0.0)
printf("You entered 0.");
else
printf("You entered a negative number.");
}
else
printf("You entered a positive number.");
return 0;
}


//Positive , Negative or Zero using function

#include<stdio.h>
#include<conio.h>
void check(int);
main()
{
int n;
printf("Input any number=");
scanf("%d",&n);
check(n);
getch();
}
void check(int a)
{
if(a>0)
printf("%d is positive number",a);
else if(a<0)
printf("%d is negative number",a);
else
printf("%d is zero",a);
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Enter Captcha Here : *

Reload Image