Program will calculate the profit and loss based on selling price and cost price


/* The user of the system will input the Cost Price and Selling Price of an item and based on the input the program will calculate whether the shopkeeper had made a profit or loss

If Selling Price - Cost Price > 0
Profit is dere
If Selling Price - Cost Price = 0
No Profit No Loss situation
If Selling Price - Cost Price < 0
Loss has incurred

*/

//_______________Include Header Files______________

#include<stdio.h>

#include<conio.h> //___________Mainly included for the getch() function___________________

int main() //___________Main is the fucntion from where the program execution starts_______________
{
float cost_price = 0, selling_price = 0; //___________Variable Declaration and Initialization___________

double pro_loss = 0;

printf("\n\n\t __________Program will calculate Profit or Loss__________");

printf("\n\n\n Enter the Cost Price - $ "); //___________Prompting the user to enter the cost price of the item______________

scanf("%f",&cost_price); //___________Reading the user input and storing it in a variable of type float___

printf("\n\n Enter the Selling Price - $ "); //___________Prompting the user to enter the selling price of the item___________

scanf("%f",&selling_price); //___________Reading the user input and storing it in a variable of type float___

pro_loss = selling_price - cost_price; //___________Calculating the amount that is left after subtracting cost price from selling price___________

if (pro_loss > 0) //___________Checking for profit__________
{
printf("\n\n\t\t _________Profit has incurred_________");
}
else if (pro_loss == 0)
{
printf("\n\n\t\t _________No Profit, No Loss_________");
}
else //__________Checking for Loss_____________
{
printf("\n\n\t\t _________Loss has incurred_________");
}

printf("\n\n\n\t\t\t Amount - $ %.2lf", pro_loss); //__________Displaying the amount_________

printf("\n\n________________________________________________________________________________");

getch();

return 0; //_________Return 0 tells teh compiler that program has executed successfully without any error____________

}



OUTPUT







Composed By :-Assignment-Hub


Posted By :- Cplusplusprogramming
Designed By Blogger Templates | Templatelib & Distributed By Blogspot Templates