Write C program to accept the cost price and selling price from the user. Find out if the seller has made a profit or loss and display how much profit or loss has been made.
#include<stdio.h>
#include<conio.h>
void main()
{
int cp,sp; //cp=cost price, sp=selling price
float profit,loss;
//accept cost price and cost price
printf("\nEnter cost price: ");
scanf("%d",&cp);
printf("\nEnter selling price: ");
scanf("%d",&sp);
//check selling price is greater than cost price or not
if(sp<cp)
{
loss=(cp-sp);
printf("\nSeller has made loss");
printf("\nloss = %f Rs.",loss);
}
else if(sp>cp)
{
profit=(sp-cp);
printf("seller has made profit");
printf("\nprofit= %f Rs.",profit);
}
else
{
printf("seller has made nor profit nor loss");
}
getch();
}
-
Next Accept radius from the user and write a program having menu with the following options and corresponding actions Options Actions 1. 1. Area of Circle Compute area of circle and print 2. Circumference of Circle Compute Circumference of circle and print 3. Volume of Sphere Compute Volume of Sphere and print
-
Previous Write a program to accept two numbers as range and display multiplication table of all numbers within that range.
0 Comments