Tuesday, 17 January 2012

Write a function named "digit_name" that takes an integer argument in the range from 1 to 9, inclusive, and then prints the English name for that integer on the computer screen. The function should not return a value.

Write a function named "digit_name" that takes an integer argument in the range from 1 to 9, inclusive, and then prints the English name for that integer on the computer screen. The function should not return a value.




#include<iostream>

#include<conio.h>

#include<process.h>



using namespace std;



int main()

{

    void digit_name(int a);

    int a;

    cout<<"Enter a number for its English Word = ";

    cin>>a;



    digit_name(a);



    getche();

    return 0;

}

void digit_name(int a)

{

    char names[9][6]={"One","Two","Three","Four","Five","Six","Seven","Eight","Nine"};



    if(a>=1 && a<=9)

        cout << names[a-1];

    else

        cout<<".....Digit Error...\n";

}

No comments:

Post a Comment