#include <iostream>
using namespace std;
int width;
int getWidth()
{
int i;
cin >> i;
if (5 <= i && i <= 70)
{
int width = i;
}
else
{
cout << "ERROR: The Range Allowed for the Width is 5 to 70, Please try again." << endl;
getWidth();
}
return width;
}
int main() {
cout << "Welcome to the Flag Generator." << endl;
cout << "Please enter the Width of your Flag." << endl;
int getWidth();
cout << "Your width is: " << width << endl;
}
I'm having problems with my code, this is just a sample of the full code and I am not even receiving a prompt from cin
to enter in a width it is just always equal to 0.
I am very new to coding and was hoping to find some answers for it. The output is:
Please enter the Width of your flag.
Your width is: 0
There is not prompt to put in an input even though there is a cin
.