C program to print number in words using switch case


Asked by admin @ in Computer Science viewed by 363 People


C program to display the number in words using switch case where a sample input and output is given

Answered by admin @



#include <stdio.h>


int main()

{

   int n, num = 0;

   printf("Enter any number to print in words: ");

   scanf("%d", &n);

   while(n != 0)

   {

       num = (num * 10) + (n % 10);

       n /= 10;

   }

   while(num != 0)

   {

       switch(num % 10)

       {

           case 0:  

               printf("Zero ");

               break;

           case 1:  

               printf("One ");

               break;

           case 2:  

               printf("Two ");

               break;

           case 3:  

               printf("Three ");

               break;

           case 4:  

               printf("Four ");

               break;

           case 5:  

               printf("Five ");

               break;

           case 6:  

               printf("Six ");

               break;

           case 7:  

               printf("Seven ");

               break;

           case 8:  

               printf("Eight ");

               break;

           case 9:  

               printf("Nine ");

               break;

       }

       

       num = num / 10;

   }


   return 0;

}


Similar Questions

C program to count number of words in a file

Asked by admin @ in Computers and Technology viewed by 351 persons

Write a c program to count the total number of commented characters and words in a c file taking both types of c file comments (single line and block) into …

C++ program to add two complex numbers using class

Asked by admin @ in Computer Science viewed by 404 persons

Write a c++ program to perform addition of two complex numbers using classes​

Python program to print first n numbers divisible by 5

Asked by admin @ in Computer Science viewed by 357 persons

Write a Python program using while loop first N numbers divisible by 5.

Describing motion using words instead of numbers is called kinematics

Asked by maham237 @ in Physics viewed by 319 persons

Program to find sum of two numbers in c++

Asked by admin @ in Computer Science viewed by 353 persons

Write a program in C++ to display the sum of two numbers 20 and 30.

Write a c++ program to accept and print your name

Asked by admin @ in Computer Science viewed by 330 persons

Write a C++ program to accept and print your name?​

C++ program to calculate area of rectangle using constructor

Asked by admin @ in Computer Science viewed by 350 persons

C++ program to calculate area of traingle circle and rectangle using constructor overloading

C++ program to perform arithmetic operations using objects and classes

Asked by admin @ in General viewed by 416 persons

How do you write a C++ program to find the arithmetic operations on complex numbers using operator overloading using the C++ language?

C programing

Asked by pranav94 @ in Engineering viewed by 470 persons

What word means the use of science for practical purposes

Asked by admin @ in Engineering viewed by 409 persons

Which term refers to the practical applications of scientific knowledge

Explain in your own words why scientists use significant figures

Asked by admin @ in Mathematics viewed by 383 persons

20 points, Thanks for the help! In your own words, describe the rules for significant digits when adding. Then, describe the rules for significant digits when multiplying in your own …

When was the word christian first used in the bible

Asked by admin @ in Biology viewed by 307 persons

Where was the word Christian first used

Write a program to split number into digits in java

Asked by admin @ in Computers and Technology viewed by 335 persons

Write a Java program that asks the user to enter a 10-digit string as a typical U.S. telephone number, extracts the 3-digit area code, the 3-digit "exchange," and the remaining …

Transitional word used after a semicolon in a compound sentence

Asked by admin @ in English viewed by 334 persons

Which accurately explains the correct use of a semicolon the selected sentence? Hawaii is the hottest state; Alaska is the coldest. A) A semicolon can link two closely related independent …

Which word best describes the tone used in both excerpts

Asked by admin @ in English viewed by 393 persons

Which word best describes the tone used in both excerpts? frustrated passionate wishful insincere

Most viewed questions in Computer Science


A programmer mistakenly writes gor instead of for

Asked by admin @ in Computer Science viewed by 19019 persons


Domestic data entry operator ncert book class 9 solutions

Asked by admin @ in Computer Science viewed by 15806 persons


Information technology code 402 class 9 solutions chapter 1

Asked by admin @ in Computer Science viewed by 10971 persons



Ncert solutions for class 8 computer chapter 1 computer system

Asked by admin @ in Computer Science viewed by 10401 persons


A scrum team works on a 4 weeks sprint

Asked by admin @ in Computer Science viewed by 8721 persons


Which of the following occupies more memory in c

Asked by admin @ in Computer Science viewed by 8135 persons



A database of motor vehicles has the base entity

Asked by admin @ in Computer Science viewed by 7841 persons


The network architecture can be termed as a mcq

Asked by admin @ in Computer Science viewed by 6486 persons


Cat5 and cat6 cabling refer to which reference model layer

Asked by admin @ in Computer Science viewed by 5788 persons



Class 7 computer chapter 3 questions and answers

Asked by admin @ in Computer Science viewed by 5691 persons


Choose the correct options about usability and user experience

Asked by admin @ in Computer Science viewed by 5474 persons


Which advocates daily team meetings for coordination and integration

Asked by admin @ in Computer Science viewed by 4980 persons



Which three security features match the database security level

Asked by admin @ in Computer Science viewed by 4970 persons


Which of the dbms package is not available

Asked by admin @ in Computer Science viewed by 4682 persons


________ aid a business grow and attain its objectives

Asked by admin @ in Computer Science viewed by 4487 persons