[Tutorial 7] 12.Find the cost of 5 items if the unit price is 10.50 Rupees.

#include <stdio.h>
int main() 
{
    float unit_price = 10.50;
    int num_items = 5;
    float cost;

/* Calculate the cost*/
    cost = unit_price * num_items;

/* Display the result*/
    printf("The cost of %d items is %.2f Rupees\n", num_items, cost);

return 0;
}


This C program computes the cost of 5 items when each item's unit price is 10.50 Rupees. It multiplies the unit price by the number of items to calculate the total cost and then displays the result. By providing a simple and concise implementation, this program demonstrates the straightforward computation of total costs based on unit prices and quantities, exemplifying fundamental arithmetic operations in C programming.

Comments

Popular posts from this blog

[Tutorial 7] 14.Write a program that converts inches to centimeters. For example, if the user enters 16.9 for a Length in inches, the output would be 42.926cm. (Hint: 1 inch = 2.54 centimeters.)

[Tutorial 7] 10.Convert the given temperature in Celsius to Fahrenheit. T(°F) = T(°C) × 1.8 + 32

[Tutorial 7] 15.The figure gives a rough sketch of a running track. It includes a rectangular shape and two semi-circles. The length of the rectangular part is 67m and breadth is 21m.Calculate the distance of the running track.