Write a program that reads in numbers m, n and prints the letter X (capital X) m times | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Write a program that reads in numbers m, n and prints the letter X (capital X) m times

Write a program that reads in numbers m, n and prints the letter X (capital X) m times followed by the letter Y (capital Y) n times, all in one line. 

19th Jan 2022, 10:03 AM
RAJ VIKRAM
RAJ VIKRAM - avatar
3 Answers
- 3
#include <iostream> using namespace std; int main() { int m,n; cin>>m>>n; while(m--) cout<<"X"; while(n--) cout<<"Y"; return 0; }
19th Jan 2022, 1:49 PM
Adi Nath Bhawani
Adi Nath Bhawani - avatar
0
Okay, then write a program? If you need help, please link your code
19th Jan 2022, 10:05 AM
Lisa
Lisa - avatar
0
#include <iostream> Using namespace std; int main() { int m,n; cin>>m>>n; int i; for (i=1;i<=m;i++) cout<<"X"; cout<<" "; for(i=1;i<=n;i++) cout<<"Y"; return 0; }
6th Feb 2022, 4:45 PM
Golu Kumar