if i have a no. 895 and i have to print it in words i.e. eight nine five. i can make use of sprintf and get it printed. suppose i need to take user input for the no.and then get it printed in words how shud i programme it???
if i have a no. 895 and i have to print it in words i.e. eight nine five. i can make use of sprintf and get it printed. suppose i need to take user input for the no.and then get it printed in words how shud i programme it???
It is a rather simple program.
You read the input.
You test which number you have and print it with words.
For example:
Do this for every digit and you are doneCode:switch(number) { case 1: printf("one "); break; case 2: pritnf("two "); break; ... }
Well "eight nine five" is considerably easier than say "eight hundred and ninety five".
Just peel off each digit with /10 and %10 and you're almost done.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.