Wednesday, April 8, 2015

32. Write an algorithm for a program that input cost price (CP) and selling price (SP) and determine whether there is gain or loss.Convert this algorithm into program code.


#include <stdio.h>
#include <conio.h>
void main()
{
int cp,sp,profit,loss;
clrscr();
printf("\n Input cost price:- ");
scanf("%d", &cp);
printf("\n Input selling price:- ");
scanf("%d",&sp);
if(sp==cp)
printf("\n No profit No loss");
else
{
if (sp>cp)
{
profit=sp-cp;
printf("\n Profit = Rs %d", profit);
}
else
{
loss =cp-sp;
printf("\n Loss =Rs %d",loss);
}
}
getch();
}

No comments:

Post a Comment