Monday, January 18, 2016

Exercise given January 18, 2016


Write a small c/c++ program that accepts a single digit number from 0 to 9 and display/printf() the spelled-out word for it. ie: 5 as the input, Five as the output.

#include <stdio.h>

main()
{
    int i = 0;

    char *ones[] = {
        "Zero", "One",
        "Two", "Three",
        "Four", "Five",
        "Six", "Seven",
        "Eight", "Nine"
    };
    
    printf("\nPls enter a single digit number: \n");
    scanf("%i",&i);

printf("\n%s\n", ones[i]);

}



2 comments: