Find cost price of one item

If the total selling price of 10 items and the total profit earned on them is input through the keyboard, write a program in C to find the cost price of one item.

Program

#include<stdio.h>
#include<conio.h>
void main()
{
    float sp, profit, cp;

	printf("Enter the total selling price of 10 items\t:");
	scanf("%f",&sp);
	printf("Enter the total profit earned on 10 items\t:");
	scanf("%f",&profit);

    cp = ((sp - profit) / 10);

    printf("\nCost Price of one item = %f",cp);

	getch();
}

Output

Enter the total selling price of 10 items       :100
Enter the total profit earned on 10 items       :40

Cost Price of one item = 6.000000

Explanation

In this program, total selling price and total profit earned on 10 items is entered by user and taken in the variables named 'sp' and 'profit' respectively.

Total cost price of 10 items = total selling price of 10 items (sp) - total profit earned (profit)
Now, cost price of 1 item = (sp - profit) / 10