Write a C program to check if a given Number is zero or Positive or Negative Using if...else statement.
When multiple if else statement is being used then we use else if instead of multiple if statement.
The code is
You may read also
How To Download C Compiler Free And How To Compile And Run A Program in Mobile Or PC
Use of if else statement in c
Here we have if else statement it is a conditional operator. We have to write the condition of if statement in brackets "( )" like this if(condition), it implies that if the condition is true Only then the body of if statement will be executed. Otherwise, program control skip the body of the if statementWhen multiple if else statement is being used then we use else if instead of multiple if statement.
The code is
#include <stdio.h>
int main()
{
double number;
scanf("%lf", &number);
if(number==0)
printf("The number is 0.\n");
else if(number>0)
printf("Positive number.\n");
else
printf("Negative number.\n");
}
Input Output0 The number is 0. -0.9 Negative number. |
You may read also
How To Download C Compiler Free And How To Compile And Run A Program in Mobile Or PC
0 Comments