Que : Write a C program to calculate profit or loss.
Ans :
#include <stdio.h>
int main()
{
int CP,SP,PL; //( for understanding pl= profilt and loss)
printf("Enter Cost Price: ");
scanf("%d", &CP);
printf("Enter Selling Price: ");
scanf("%d", &SP);
if(SP>CP)
{
PL= SP-CP;
printf("\nYou are in profit and the amount is : %d\n",PL);
}
else
if(CP>SP)
{
PL = CP-SP;
printf("\nYou get loss of amount : %d\n", PL);
}
else
{
printf("\nYou get no profit no loss .\n");
}
}
Input :
-----------------------------------------------------------------------------------------------------------------------------
Comments
Post a Comment