Print 1 pen cost price in C
printf() - Question 14
In this question, we will see how to print the cost of one pen if the cost of 12 pens is Rs. 150 in C programming using the printf() function. To know more about printf() function click on the printf() function lesson.
Q14) Write a program in C to print the cost of one pen if the cost of 12 pens is Rs. 150.
Program
#include <stdio.h>
#include <conio.h>
int main()
{
printf("Cost of 12 pens = Rs.150\n");
printf("Cost of 1 pen = Rs.%f",150/12.0);
return 0;
}
Output
Cost of 12 pens = Rs.150 Cost of 1 pen = Rs.12.500000