i need the code for a program that using the do while and while will make a prog
ID: 672726 • Letter: I
Question
i need the code for a program that using the do while and while will make a program that will show a word as many times that the user wants to in visual studio c++
The code i have for know is this one and im not sure if its correct. Dont mind the // description. its in spanish.
//usuario entre un número y en la pantalla mostrara desde el numero uno hasta un numero n
#include <iostream>
using namespace std;
int main()
{
char str[10] = "hey";
int n,i;
cout << "say hey this many times"<< endl;
cin >> n;
for (i = 1; i <= n; i++)
{
cout << str;
}
return 0;
}
Explanation / Answer
#include <iostream>
using namespace std;
int main()
{
char str[10] = "hey";
int n,i = 1;
cout << "say hey this many times"<< endl;
cin >> n;
do{
cout<<str<<endl;
}while(++i <= n);
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.