Write a program to calculate profit or loss

When selling price is less than cost price, then it is said to be profit else loss.

#include<stdio.h>
void main()
{
   int CP, SP, pro, loss;
   printf("Enter cost price and selling price of an object:");
   scanf("%d %d", &CP, &SP);

   if(SP>CP)
     { 
        pro = SP-CP;
        printf("\n Profit = Rs.%d", pro);
       }
else
     {
        loss = CP-SP;
        printf("\n Loss = Rs.%d", loss);
       }
}

Post a Comment

0 Comments