(l) If the total selling price of 15 items and the total profit earned on them is input through the keyboard, write a program to find the cost price of one item.

Let Us C by Yashwant Kanetkar

 

Solution By Muhammad Kaleem UIlah



                                                                  Exercise Questions 
[H] Write C programs for the following:

(l) If the total selling price of 15 items and the total profit earned on them is input through the keyboard, write a program to find the cost price of one item.

#include <stdio.h>

#include <stdlib.h>

 

int main()

{

    float sellingprice,profit,costperitem;

    printf("\n\t\t Enter the total selling Price = ");

    scanf("%f",&sellingprice);

    printf("\n\t\t Enter the total profit = ");

    scanf("%f",&profit);

    costperitem=(sellingprice-profit)/15;

    printf("\n\t\t Cost price of one item = %f",costperitem);

    return 0;

}


Comments

Popular posts from this blog

(e) The length & breadth of a rectangle and radius of a circle are input through the keyboard. Write a program to calculate the area & perimeter of the rectangle, and the area & circumference of the circle.

(b) The distance between two cities (in km.) is input through the keyboard. Write a program to convert and print this distance in meters, feet, inches and centimeters.

(g) If a five-digit number is input through the keyboard, write a program to calculate the sum of its digits. (Hint: Use the modulus operator ‘%’)