Chapter - 3: The Decision Control

If the cost price and selling price of an item is input through the keyboard, write a program to determine whether the seller has made a profit or incurred loss. Also, determine how much profit he made or loss he incurred.


C
Sections
1
Exercises
#include<stdio.h>
#include<conio.h>
int main()
{
	float sp, cp;
	
	printf("Enter the selling price and cost price of the item : ");
	scanf("%f%f", &sp, &cp);
	
	if(sp-cp&gt;0)//profit condition
		printf("\n\nThe seller has gained profit of %f Rs.", sp-cp);
	else if(sp-cp<0)//loss condition
		printf("\n\nThe seller has incurred a loss of %f Rs.", cp-sp);
	else//condition of no profit no loss
		printf("\n\nThe seller neither in profit nor in loss.");
	
	getch();
	return 0;
}

© 2021 Garbage Valuegarbage value logo