Note that there are some explanatory texts on larger screens.

plurals
  1. POSimple C Program To Convert Two Digits Into Words
    primarykey
    data
    text
    <p>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.</p> <pre><code>#include &lt;stdio.h&gt; int main (void) { int firstNum, secondNum; printf("Enter a two digit number: "); scanf("%d%d", &amp;firstNum,&amp;secondNum); if (firstNum == 1 &amp;&amp; secondNum == 0){ printf("You entered the number ten\n");} if (firstNum == 1 &amp;&amp; secondNum == 1){ printf("You entered the number eleven\n");} if (firstNum == 1 &amp;&amp; secondNum == 2){ printf("You entered the number twelve\n");} if (firstNum == 1 &amp;&amp; secondNum == 3){ printf("You entered the number thirteen\n");} if (firstNum == 1 &amp;&amp; secondNum == 4){ printf("You entered the number forteen\n");} if (firstNum == 1 &amp;&amp; secondNum == 5){ printf("You entered the number fifteen\n");} if (firstNum == 1 &amp;&amp; secondNum == 6){ printf("You entered the number sixteen\n");} if (firstNum == 1 &amp;&amp; secondNum == 7){ printf("You entered the number seventeen\n");} if (firstNum == 1 &amp;&amp; secondNum == 8){ printf("You entered the number eighteen\n");} if (firstNum == 1 &amp;&amp; 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; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload