IF ELSE STATEMENT
In this tutorial we are going to see how if else statement work
and how to perform a simple EB billing
program using if else statement…..
We are using stdio.h in a program to get standard
input and output of the program.
We are using units and c
as a variable and in print statement
we are giving enter the no of units and in
scanf we are giving %d to declare a variable here.
And in if statement now we are giving a condition units>100 the following statement
are printed and in c we are delaring
c=units*5 .
In print statement we are
using %d to declare the integer
value of c.
If the condition is
false the else condition will
run to get the output.
Here we are using c=units*3 . In print statement we are
using %d to declare the integer
value of c.
We are using return 0 to declare the program is end.
PROGRAM:
include <stdio.h>
int main()
{
int units,c;
printf("Enter the no.of.units : ");
scanf("%d",&units);
if(units>100)
{
c=units*5;
printf("The bill amount is
:%d\n",c);
}
else
{
c=units*3;
printf("The bill amount is :%d\n",c);
}
return 0;
}
OUTPUT
Enter
no.of units:103
The
bill amount is:515