So i was doing my Intro to c++ homework and i cant seem to get it right.
The Goal is : Make a program that asks the user for two one digit numbers from 1-9. The first number the user enters will be printed to the screen the number of times of the second number entered. (i.e. if “4″ is the first number and “5″ is the second number, “4″ will be printed five times.)
Here is the code
#include <iostream>
using namespace std;
int getOneDig(){
int x;
cout <<"Please enter for x";
cin >> x;
while( x>9 && x<1){
cout<<"Please enter for x";
cin>>x;
}
return x;
int repdig(){
for (int x=1; x<=y; x++);
}
cout << y;
return y;
}
int main()
{
int x = getOneDig();
int y = getOneDig();
cout<<repDig(x,y)<<endl;
return 0;
}
And here are the errors i get.
sija6.cpp: In function âint getOneDig()â:
sija6.cpp:14: error: a function-definition is not allowed here before â{â token
sija6.cpp:17: error: âyâ was not declared in this scope
sija6.cpp: In function âint main()â:
sija6.cpp:26: error: ârepDigâ was not declared in this scope