Â

In this, we are going to write a program to Calculate Profit or Loss with the help of C programming language.
#include <stdio.h>
void main()
{
int cost_price, selling_price, amount;
// Input cost price and selling price of a product
printf("Enter Cost price: ");
scanf("%d", &cost_price);
printf("Enter Selling price: ");
scanf("%d", &selling_price);
if (selling_price > cost_price)
{
// Calculate Profit
amount = selling_price - cost_price;
printf("Profit = %d", amount);
}
else if (cost_price > selling_price)
{
// Calculate Loss
amount = cost_price - selling_price;
printf("Loss = %d", amount);
}
else
{
// Neither profit nor loss
printf("No Profit No Loss.");
}
}
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP