WAP to read the price of an item in decimal form (like 15.95) and print the output in paise (like 1595 paise)

//E Balagurusamy, Programming In ANSI C,4E
//Exercise 2.2, page 51
#include <stdio.h>
#include <conio.h>
#include <math.h>
int main(void)
{float amount_input=0.0;
int amount_in_paise=0;

printf("\n\n");
printf("Enter the price Rupees.Paise : ");
scanf("%f",&amount_input);
amount_in_paise = amount_input * 100;
//in the above statement, we have data types
//INT = FLOAT * INT;
//this results in the required ignoring of any precision
//beyond two decimal points...
//Why?
//Because in Indian Rupees, 1 Rupee = 100 Paise
printf("Amount in Paise : %d", amount_in_paise);
printf("\n");
getch();
return 0;
}

Comments