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 7725539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:57:51+00:00 2026-06-01T04:57:51+00:00

What I am trying to do is to write a program wherein you input

  • 0

What I am trying to do is to write a program wherein you input two digits and
then they are converted into words which gets printed. The problem is that this program
hangs after you input the two digits and I have no idea why. Any and all help is appreciated.
I am a beginner and all I can use to solve this is basically if and switch. Thanks again.

#include <stdio.h>

int main (void)
{
    int firstNum, secondNum;

    printf("Enter a two digit number: ");
    scanf("%d%d", &firstNum,&secondNum);

    if (firstNum == 1 && secondNum == 0){
            printf("You entered the number ten\n");}
    if (firstNum == 1 && secondNum == 1){
                printf("You entered the number eleven\n");}
    if (firstNum == 1 && secondNum == 2){
                printf("You entered the number twelve\n");}
    if (firstNum == 1 && secondNum == 3){
                printf("You entered the number thirteen\n");}
    if (firstNum == 1 && secondNum == 4){
                printf("You entered the number forteen\n");}
    if (firstNum == 1 && secondNum == 5){
                printf("You entered the number fifteen\n");}
    if (firstNum == 1 && secondNum == 6){
                printf("You entered the number sixteen\n");}
    if (firstNum == 1 && secondNum == 7){
                printf("You entered the number seventeen\n");}
    if (firstNum == 1 && secondNum == 8){
                printf("You entered the number eighteen\n");}
    if (firstNum == 1 && secondNum == 9){
                printf("You entered the number nineteen\n");}
    switch(firstNum){
        case 2: printf("You entered the number twenty-");break;
        case 3: printf("You entered the number thirty-");break;
        case 4: printf("You entered the number forty-");break;
        case 5: printf("You entered the number fifty-");break;
        case 6: printf("You entered the number sixty-");break;
        case 7: printf("You entered the number seventy-");break;
        case 8: printf("You entered the number eighty-");break;
        case 9: printf("You entered the number ninty-");break;
    }
    switch (secondNum){
        case 1: printf("one.\n");break;
        case 2: printf("two.\n");break;
        case 3: printf("three.\n");break;
        case 4: printf("four.\n");break;
        case 5: printf("five.\n");break;
        case 6: printf("six.\n");break;
    }
    return 0;
}
  • 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-06-01T04:57:53+00:00Added an answer on June 1, 2026 at 4:57 am

    Your program “hangs” because it is waiting for a second number.

    Instead of 42ENTER, type 42fooENTER.


    You need to verify the return value from scanf()

    if (scanf("%d%d", &firstNum, &secondNum) != 2) {
        fprintf(stderr, "Oops, the scanf didn't read 2 numbers.\n");
    } else {
        /* continue with program */
        /* you might as well see what scanf got from the input */
        printf("scanf got the values %d and %d.\n", firstNum, secondNum);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to write a program which get two 6-digit decimal numbers and show
I'm trying to write a program that determines whether two words are cognates. I've
i am trying to write a program that close explorer then runs another program.
I am trying to write a program that takes an input of of n
I'm trying to write a program which, at some point, needs to invoke an
I am trying to write simple program using ONLY for loop ( if then
Im trying to write a program that takes a txt file as input, and
I'm trying to write a program which will run when a Windows Mobile device
Am trying to write a program for AVR STK600 board in which am cycling
I'm trying to write a program which calls a library function ( http://www.diku.dk/hjemmesider/ansatte/pisinger/3dbpp.c )

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.