If the cost price and selling price of an item is input through the keyboard, write a program in C to determine whether the seller has made profit or incurred loss. Also determine how much profit he made or loss he incurred.
#include <stdio.h>
#include <conio.h>
void main() {
float cost, sell, profit;
clrscr();
textcolor(YELLOW);
cprintf("Cost Price : Rs.");
scanf("%f", &cost);
cprintf("Selling Price : Rs.");
scanf("%f", &sell);
if(sell > cost) {
profit=sell-cost;
cprintf("\nProfit : Rs.%.2f", profit);
} else if(sell == cost) {
cprintf("\nNo profit - No loss");
} else {
profit=cost-sell;
cprintf("\nLoss : Rs.%.2f", profit);
}
getch();
}
#include <conio.h>
void main() {
float cost, sell, profit;
clrscr();
textcolor(YELLOW);
cprintf("Cost Price : Rs.");
scanf("%f", &cost);
cprintf("Selling Price : Rs.");
scanf("%f", &sell);
if(sell > cost) {
profit=sell-cost;
cprintf("\nProfit : Rs.%.2f", profit);
} else if(sell == cost) {
cprintf("\nNo profit - No loss");
} else {
profit=cost-sell;
cprintf("\nLoss : Rs.%.2f", profit);
}
getch();
}
Post a Comment