instanceof java
Posts: 576
Nickname: instanceof
Registered: Jan, 2015
instanceof java is a java related one.
C program to print given number in words
Posted: May 19, 2017 7:22 PM
This post originated from an RSS feed registered with Java Buzz
by instanceof java.
Original Post: C program to print given number in words
Feed Title: Instance Of Java
Feed URL: http://feeds.feedburner.com/blogspot/TXghwE
Feed Description: Instance of Java. A place where you can learn java in simple way each and every topic covered with many points and sample programs.
Latest Java Buzz Posts
Latest Java Buzz Posts by instanceof java
Latest Posts From Instance Of Java
Advertisement
Write a program to input a digit and print it in words C program to print number in words using switch cas. Now we will see how to convert number /digits in to words in C programming. Get the input from the user using Scanf() function. Using while loop and % operator and get the each number and use switch case to print corresponding word for the current number.
Program #1: write a program in c that reads the digits and then converts them into words #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int number,i=0,j,digit; char * word[1000]; printf("Enter any integer to print that in words: "); scanf("%d",&number); while(number){ digit = number %10; number = number /10; switch(digit){ case 0: word[i++] = "zero"; break; case 1: word[i++] = "one"; break; case 2: word[i++] = "two"; break; case 3: word[i++] = "three"; break; case 4: word[i++] = "four"; break; case 5: word[i++] = "five"; break; case 6: word[i++] = "six"; break; case 7: word[i++] = "seven"; break; case 8: word[i++] = "eight"; break; case 9: word[i++] = "nine"; break; } } for(j=i-1;j>=0;j--){ printf("%s ",word[j]); } return 0; } Output:
Read: C program to print given number in words