Enter the next number (1-10): 7 [Enter] $$$$$$$ Enter the next number (1-10): 11
ID: 3566803 • Letter: E
Question
Enter the next number (1-10): 7 [Enter]
$$$$$$$
Enter the next number (1-10): 11 [Enter]
That is an invalid number.
Enter the next number (1-10): 10 [Enter]
$$$$$$$$$$
Enter the next number (1-10): 5 [Enter]
$$$$$
Enter the next number (1-10): 3 [Enter]
$$$
Enter the next number (1-10): 2 [Enter]
$$
so far i have
#include <iostream>
using namespace std;
int main()
{
int x, y;
cout << "Enter an integer in the range 1-20: ";
cin >> x;
cout << "Enter another integer in the range "
<< "1-20: ";
cin >> y;
for (int i = 1; i <= y; i++)
{
for (int j = 1; j <= x; j++)
{
cout << '$';
}
cout << endl;
}
return 0;
}
Explanation / Answer
#include <iostream>
using namespace std;
int main()
{
int x;
cout << "Enter an integer in the range 1-10: ";
cin >> x;
if(x<=10)
{
for (int i = 1; i <= x; i++)
{
cout << '$';
}
}
else
cout<<"not valid";
return 0;
}
this is an simple program for your desired output
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.