A C++ program to print a value(n) n times using for loop
This program will print the given value(n), the same number of times. For loop is used to execute this task. The loop will run from 1 to n and in each execution prints n in a new line.
Code
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++){
cout<<n<<endl;
}
return 0;
}
Input
5
Output
5
5
5
5
5
0 Comments