Thanks ahead of time for reading, and any help you give.
Basically I have a integer "numExs" that is initialized by user input. Then, I use a for loop to output the appropriate number of X's, as dictated by the "numExs" integer.
However, I get a C4700 warning that "numExs" is not an initialized local variable. If I am reading it right then 'local' is the keyword there, but I don't know how to re-initialize it. The program does not run with the warning.
Any help would be appreciated. Many thanks.
/*Write a program that asks the user for a number between 1 and 10, then prints a line of that many “X”s
as shown below. Reject any entries outside of the range of 1 to 10 by displaying “Entry is out of range.”
You must use a FOR LOOP for this problem. The variable used to store the number of Xs must be called
“numExs”.*/
#include <iostream>
using namespace std;
int main()
{
int numExs;
int counter;
cout<<"Please enter the number of Xs (1-10): ";
cin>>numExs;
counter = numExs;
for (int numExs; counter>0; counter--) // C4700 ERROR HERE
{
if (numExs>0 && numExs<11)
{
cout<<"X";
}
else
{
cout<<"Entry is out of range.";
}
}
cout<<endl;
}