Wednesday 24 July 2013

Chapter 2 Solutions Problem [C](a)

Question. If cost price and selling price of an item is input through the keyboard,
 write a program to determine whether the seller has made profit or incurred loss. Also determine how much profit he made or loss he incurred. 
solution- fairly easy one.

#include<stdio.h>

int main()
{
int cp,sp,profit,loss;
printf("Enter the Cost price and selling price\n");
scanf("%d%d",&cp,&sp);
if(cp<sp)
printf("Profit earned is =%d\n",sp-cp);
else if (cp>sp)
printf("Loss incurred is=%d\n,cp-sp);
else
printf("no profit no loss\n");
return 0;
}

No comments:

Post a Comment