TechoSagar: C++ Loops | Set 1 (Print a string N times)

Search

Google Alert - jobs

C++ Loops | Set 1 (Print a string N times)

Given an integer N. The task is to print "GeeksforGeeks" N times (without quotes). Every time "GeeksforGeeks" will be printed on a new line.
Input:
The first line contains a single integer T i.e. the number of test cases. Each test case contains a single integer N representing number of times the string "GeeksforGeeks" will be printed.
 
Output:
Corresponding to each test case, print "GeeksforGeeks" N times (without quotes), every time on a new line.
Constraints:
1<=T<=20
1<=N<=100
Example:
Input:
2
3
2
Output:
GeeksforGeeks
GeeksforGeeks
GeeksforGeeks
GeeksforGeeks
GeeksforGeeks
Your Code
#include<iostream>
using namespace std;
int main()
 {
int n;
cin>>n;
int i;
for(i=1; i<=n; i++)
{ int j;
int N;
cin>>N;
   for(j=1; j<=N; j++)
   {
       cout<<"GeeksforGeeks"<<endl;
   }
}
return 0;
}

Follow us

Follow Bijendra Kumar on Facebook