Read a whole number from 1 to 9

Monday, June 14, 2010

C08_Ex 1: Input a  whole number.Reading this whole number with value from 1 to 9.Default, Output:  "Don't know how to read".

// Input a  whole number.
// Reading this whole number with value from 1 to 9.
// Default, output Don't know how to read.
// Use Visual Studio 2005

#include <stdio.h>

void main()
{
    int n;
    printf("Input a  whole number: ");
    scanf("%d", &n);
   
    switch (n)
    {
        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;
        default: printf("Don't know how to read!");
    }

    printf("\n");
}

0 Comments:

Post a Comment

 
 
 
 
Copyright © 2010 C Source Code - C++ Source Code. All Rights Reserved. Using Xclear Theme | Bloggerized by Themescook Developed by Helios | Powered by Blogger