Computer Science, asked by nuha46, 1 year ago

write a c++ program to accept the cost price and selling price and the display whether it is profit or loss​

Answers

Answered by aakashvoora
2

int main()

{

   int cp,sp, amt;

   

   /* Input cost price and selling price of a product */

   printf("Enter cost price: ");

   scanf("%d", &cp);

   printf("Enter selling price: ");

   scanf("%d", &sp);

   

   if(sp > cp)

   {

       /* Calculate Profit */

       amt = sp - cp;

       printf("Profit = %d", amt);

   }

   else if(cp > sp)

   {

       /* Calculate Loss */

       amt = cp - sp;

       printf("Loss = %d", amt);

   }

   else

   {

       /* Neither profit nor loss */

       printf("No Profit No Loss.");

   }

   return 0;

}


nuha46: we shouldn't use print or scan it should be cout n cin
aakashvoora: use could use that also
nuha46: teacher wont allow
aakashvoora: then umm... replace print by the function that your teacher has expressed that is cout
Similar questions