Writing the Word Equivalent of a Check Amount One common sec
Writing the Word Equivalent of a Check Amount: One common security method requires that the check amount be both written in numbers and ”spelled out” in words. Even if someone is able to alter the numerical amount of the check, it’s extremely difficult to change the amount in words. Write a program that inputs a numeric check amount and writes the word equivalent of the amount. For example, the amount 52.43 should be written as FIFTY TWO and 43/100. Note: The program only needs to handle values up to 99.99. The program can easily be modified to process larger values.
please do it in c program
Solution
#include <stdio.h>
#include <math.h>
int main()
{
char a[10][10]={\"ONE\",\"TWO\",\"THREE\",\"FOUR\",\"FIVE\",\"SIX\",\"SEVEN\",\"EIGHT\",\"NINE\"};
char b[10][10]={\"ELEVEN\",\"TWELVE\",\"THIRTEEN\",\"FOURTEEN\",\"FIFTEEN\",\"SIXTEEN\",\"SEVENTEEN\",\"EIGHTEEN\",\"NINTEEN\"};
char c[10][10]={\"TEN\",\"TWENTY\",\"THIRTY\",\"FOURTY\",\"FIFTY\",\"SIXTY\",\"SEVENTY\",\"EIGHTY\",\"NINTY\"};
int no,t,p,dec;
float Num;
printf(\"Enter the number: \");
scanf(\"%f\",&Num);
int intpart = (int)Num;
float decpart = Num-intpart;
decpart = ((int)(decpart * 100 + .5) / 100.0);
dec=(int)(decpart*100);
no=intpart;
if(no>=10 && no<20)
{
t=no%10;
printf(\"%s\",b[t-1]);
}
if(no>19 && no<=100)
{
t=no/10;
no=no%10;
printf(\"%s\",c[t-1]);
}
if(no<10)
{
printf(\"%s\",a[no-1]);
}
printf(\" and %d/100\", dec);
return 0;
}
