I am trying to create a program that will take a number you give to the input and then it will check through my calc() function what number it is then prints it out as a string from the integer you gave it. I am new to this so can anyone help me with my code?
Error: Too few arguments to function
p.s Tip would be greatly appreciated. I am not sure if I am doing my functions correctly
Code:
#include <iostream>
using namespace std;
// Function prototype
int zero(int x);
int one_through_nine(int x);
int tenUp(int x);
int twenties(int x);
int calc(int x);
int main()
{
// Take input
int result;
cout << "Enter number: " << endl;
cin >> result;
// Run input through calc function
cout << calc(result);
return 0;
}
// Returns 0
int zero(int x){
if(x < 1){
cout << "zero";
}
return x;
}
// Returns 1 - 9
int one_through_nine(int x){
if(x == 1){
cout << "one";
}else if(x == 2){
cout << "two";
}else if(x == 3){
cout << "three";
}else if(x == 4){
cout << "four";
}else if(x == 5){
cout << "five";
}else if(x == 6){
cout << "six";
}else if(x == 7){
cout << "seven";
}else if(x == 8){
cout << "eight";
}else if(x == 9){
cout << "nine";
}
return x;
}
// Returns 10 - 20
int tenUp(int x){
if(x == 10){
cout << "ten";
}else if(x == 11){
cout << "eleven";
}else if(x == 12){
cout << "twelve";
}else if(x == 13){
cout << "thirteen";
}else if(x == 14){
cout << "fourteen";
}else if(x == 15){
cout << "fifteen";
}else if(x == 16){
cout << "sixteen";
}else if(x == 17){
cout << "seventeen";
}else if(x == 18){
cout << "eighteen";
}else if(x == 19){
cout << "eleven";
}
return x;
}
// Returns numbers 20 - 29
int twenties(int x){
if(x == 20){
cout << "twenty";
}else if(x < 30){
cout << "twenty -" << one_through_nine();
}
return x;
}
// Calculates what function x will be put through
int calc(int x){
if(x == 0){
cout << zero(x);
} else if(x < 10){
cout << one_through_nine(x);
}else if(x < 20){
cout << tenUp(x);
}else if (x < 30){
cout << twenties(x);
}else{
cout << "Numbers are under construction.\nSorry for the inconvenience." << endl;
return x;
}
return x;
}