C program to Calculate Profit or Loss Using If Else ?
Q:- Write a C program to Calculate Profit or Loss Using If Else ?
Input
#include<stdio.h
#include<conio.h>
int main()
{
float cp, sp, amt;
clrscr();
printf(“Enter Cost Price =”);
scanf(”%d”,&cp);
printf(“Enter Selling Price =”);
scanf(“%d”,&cp);
if(cp>sp)
{
amt=cp-sp;
printf(“Loss=%d”,amt);
}
else if(sp>cp)
{
amt=sp-cp;
printf(“Profit=%d”,amt);
}
else
{
printf(“No Profit No Loss.”);
}
getch();
}
Output
Enter Cost
Price = 1000
Enter
Selling Price = 1500
Profit =
500
Comments
Post a Comment