P018.c ​
Metadata ​
- Author — Amit Dutta (amitdutta4255@gmail.com)
- Last updated — 12 Dec 2025
- License — MIT
Problem Statement ​
Problem Statement
WAP to input the cost price and selling price and calculate profit, profit percentage, loss percentage or display the manage nither profit nor loss.
Source Code ​
Printing the code
To print this file, open it on GitHub and click Raw before printing, or use the Download Raw button above and print directly from that page.
c
#include <stdio.h>
int main()
{
double cost, sell, pro, prop, loss, lossp;
printf("Enter the cost and selling price : ");
scanf("%lf %lf", &cost, &sell);
if (sell > cost)
{
pro = sell - cost;
prop = (pro / cost) * 100;
printf("Profit : RS %g, Profit Percentage : %g", pro, prop);
}
else if (sell < cost)
{
loss = cost - sell;
lossp = (loss / cost) * 100;
printf("Loss : RS %g, Loss Percentage : %g", loss, lossp);
}
else
printf("Neither loss nor Profit.");
return 0;
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22