Using a do while loop, write a program that will accept the name of the user and display “the user name” N number of times.
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
int i=1;
int N;
string name;
cout<<"Enter N: ";
cin>>N;
cout<<"Enter the name: ";
cin.ignore();
getline(cin,name);
do {
cout<<name<<"\n";
i++;
} while (i<=N);
system("pause");
return 0;
}
Comments
Leave a comment