Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6232689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:09:36+00:00 2026-05-24T10:09:36+00:00

I want to make a program in C which will ask the user to

  • 0

I want to make a program in C which will ask the user to input a number and then it will print that number in English.

For example:

if(INPUT == 1) then print ONE
if(INPUT == 2) then print TWO

and so on. It can be made using switch-case and if else but it makes the code lengthy. For few numbers it’s fine but if we have to write up to 100 then it will be lengthy.

Is there a short algorithm or idea for this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T10:09:37+00:00Added an answer on May 24, 2026 at 10:09 am

    You can use the below, but this prints only upto thousands. I did this to solve some particular programming problem. Thats why i did not extend beyond thousands. But its not hard to extend for bigger number. Also, this program can be still optimized or made more clearer.

    #include <stdio.h>
    #include <string.h>
    
    void print(int num) {
        char digit [21][10] = { "", "one", "two", "three", "four", "five", "six", "seven",
                              "eight", "nine", "ten", "eleven", "twelve", "thirteen", 
                              "fourteen", "fifteen", "sixteen", "seventeen", "eighteen",
                              "nineteen"};
        char tens [11][10] = { "", "", "twenty", "thirty", "forty", "fifty", "sixty", 
                             "seventy", "eighty", "ninety"};
        char str[1000] = {0};
        int prev=0, div=1000;
        strcpy(str, "");
    
        while(div) {
    
            if ((num / div) % 10 > 0 || (div == 10 && (num%100) > 0)) { 
    
                if (prev) {
                    strcat(str, "and");
                    prev = 0;
                }
    
                switch(div) {
                case 1000:
                    strcat(str, digit[(num / div) % 10]);     
                    strcat(str, "thousand");
                    prev = 1;
                    break;
                case 100:
                    strcat(str, digit[(num / div) % 10]);     
                    strcat(str, "hundred");
                    prev = 1;
                    break;
                case 10:
                    if ( (num%100) >= 10 && (num%100) <= 19)
                        strcat(str, digit[num%100]);
                    else {
                        strcat(str, tens[(num%100)/10]);
                        strcat(str, digit[num%10]);
                    }
                    break;
                }
            }
    
            div /= 10;
        }
        printf("%d %s\n", num, str);
    
    }
    int main(int argc, char **argv) {
    
        long sum = 0;
        int count = 0;
    
        if (argc <= 1) {
            fprintf(stderr, "wrong number of arguments\n");
            return -1;
        }
    
        print(atoi(argv[1]));
    
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make a program that will simulate a user browsing a site
I want to make a program that will read some number in string format
Basically I want to make simple toggle program (that will be mapped to some
I want to make a script that starts a program and then sends it
I want to make a program which will determine the Rank of a given
I want to make program that encrypts (later decrypts) user inputted string. Here is
I want to implement in my program functionality, which will make it able to
I need to write a program, that will ask a user to enter a
Ok, I want to make my program print out the date: 1/1/2009 But this
I want to make a C# program that can be run as a CLI

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.