Given a number as input, if the number is between 1 and 10 both inclusive then print the number in words otherwise print "not in range".
Input:
First line of input contains an integer T which denotes the number of test cases. Then T test cases follows. First line of each test case contains an integer N.
First line of input contains an integer T which denotes the number of test cases. Then T test cases follows. First line of each test case contains an integer N.
Output:
For each test case, if the number is between 1 and 10 both inclusive then print the number in words in small cases otherwise print "not in range"
For each test case, if the number is between 1 and 10 both inclusive then print the number in words in small cases otherwise print "not in range"
Constraints:
1<=T<=1000
1<=N<=100
1<=N<=100
Example:
Input:
5
5
6
12
2
10
5
6
12
2
10
Output:
five
six
not in range
two
ten
five
six
not in range
two
ten
Your code
#include <iostream>using namespace std;
int main()
{
int n,x,a,i;
cin>>a;
for(i=1; i<=a; i++){
cin>>n;
if(n<=10 && n>=1)
{
x=n%10;
switch(x)
{
case 0: cout<<"ten\n";
break;
case 1: cout<<"one\n";
break;
case 2 :
cout<<"two\n";
break;
case 3: cout <<"three\n";
break;
case 4: cout<<"four\n";
break;
case 5: cout<<"five\n";
break;
case 6: cout<<"six\n";
break;
case 7: cout<<"seven\n";
break;
case 8: cout<<"eight\n";
break;
default : cout<<"nine\n";
} }
else
cout<<"not in range\n";
}
return 0;
}