Roopa has given a program to her close friend Jhansi in the apartment where she lives. The task is if the number is given it needs to be converted into words.
It’s like writing the amount in numbers on the cell of the bank challan and then writing it in words.
Input:
The first input contains an integer T denoting the number of test cases.
The first line of each test case is N.
Output:
Print the number into words (in small letter)
#include <stdio.h> #include <string.h> int main() { const char *a[]={ "zero" , "one" , "two" , "three" , "four" , "five" , "six" , "seven" , "eight" , "nine" }; const char *b[]={ "ten" , "eleven" , "twelve" , "thirteen" , "fourteen" , "fifteen" , "sixteen" , "seventeen" , "eighteen" , "nineteen" }; const char *c[]={ " " , " " , "twenty" , "thirty" , "forty" , "fifty" , "sixty" , "seventy" , "eighty" , "ninety" }; //const char *p[]={"hundred" , "thousand" }; char num[10]; int l,n,n1; scanf("%s",num); l=strlen(num); if(l==4) { while(l--) { if(l==3&&num[0]!='0') { printf("%s thousand ",a[*num- '0']); } if(l==2 && num[1]!='0' && num[2]=='0'&&num[3]=='0') { n=num[1]-48; printf("%s hundred ",a[n]); break; } if(l==2 && num[1]!='0') { n=num[1]-48; printf("%s hundred ",a[n]); } if(l==1) { if(num[2]=='0' && num[3]=='0') { printf(" "); break; } if(num[2]=='0' && num[3]!='0') { n=num[3]-48; printf("%s",a[n]); break; } if(num[3!='0' && num[2]!='1']&& num[2]!='0') { n=num[2]-48; n1=num[3]-48; printf("and %s %s",c[n],a[n1]); break; } if(num[3]=='0'); { n=num[2]-48; printf("and %s",c[n]); break; } if(num[2]=='1'); { n=num[3]-48; printf("and %s",b[n]); break; } } } } printf("\n"); return 0; }
INPUT_1:
9851
OUTPUT:
nine thousand eight hundred and fifty one
INPUT_2:
3462
OUTPUT:
three thousand four hundred and sixty two
Morae Q!
- Conversion of days into year, weeks and days.
- Find if the number is a perfect number or not.
- Compute conversion of Binary to Octal.
- Return the sum of digits in a number.
- Find if a word exists or not in a sentence.
- Convert Numbers into Words.
- Read a word if it consists only of the letters known.
- Check if the string is a dynamic string or not.
- Convert all Uppercase letters to Lowercase and vice-versa.
- Change the string such that there are no matching adjacent characters.
- Find the number of sub-strings which start and end both in 1.
- Find the start and end index of unsorted sub-array.
- Find the maximum number of pairs that can be formed.
- Figure out the number of bubbly words present.
- Check if a string is lapindrome or not even with a middle character.
- Seating layout in a triangular shaped class according to the number of rows.
- Find and Sort a sub-array which makes whole array sorted.
- Seating layout according to the number of rows.
- Find the final states of the bulbs.
- Check if reversing sub array makes the array sorted.