[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

Introduction To C

First C Program

Compilation process in c