#include <iostream>
usingnamespace std;
int main()
{
int spaces1 = 1; // initialize spaces1 to a value of 1
int spaces;
cout << "please enter the amount of spaces you wish" << endl;
cin >> spaces;
while( spaces1 <= spaces )
{
cout << "*" << endl;
spaces1++;
}
system("pause");
return 0;
}
// OR use a for statement like this:
#include <iostream>
usingnamespace std;
int main()
{
int spaces1;
int spaces;
cout << "please enter the amount of spaces you wish" << endl;
cin >> spaces;
for ( spaces1 = 1; spaces1 <= spaces; spaces1++)
cout << " " << endl;
system("pause");
return 0;
}
#include <iostream>
#include <sstream>
#include <string>
usingnamespace std;
int main()
{
char ch;
int n;
string s;
cout << "Please enter a character (defaults to a space): ";
getline( cin, s );
if (s.empty()) ch = ' ';
else ch = s[ 0 ];
cout << "Please enter the number of times to repeat that character (minimum = 1): ";
getline( cin, s );
if (!(stringstream( s ) >> n)) n = 1;
if (n < 1) n = 1;
cout << "begin>" << string( n, ch ) << "<end\n";
return 0;
}