P018.c
Problem Statement
P018.c
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
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
● Author - Amit Dutta · Updated - 12 Dec 2025