Answer:
The program in C++ is as follows:
#include<iostream>
using namespace std;
void changenum(int num){
string nums[7] = {"One","Two","Three","Four","Five","Six","Seven"};
if(num >7 || num < 1){
cout<<"Out of range";
}
else{
cout<<nums[num-1]; }
}
int main(){
int num;
cout<<"Number: ";
cin>>num;
changenum(num);
return 0;
}
Step-by-step explanation:
The function begins here
void changenum(int num){
This initializesa string of numbers; one to seven
string nums[7] = {"One","Two","Three","Four","Five","Six","Seven"};
If the number is less than 1 or greater than 7, it prints an out of range error
if(num >7 || num < 1){
cout<<"Out of range";
}
If otherwise, the corresponding number is printed
else{
cout<<nums[num-1]; }
}
The main begins here
int main(){
This declares num as integer
int num;
Prompt the user for input
cout<<"Number: ";
Get input from the user
cin>>num;
Pass the input to the function
changenum(num);
return 0;
}