forked from bilal1718/C-Assignments
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ3.cpp
More file actions
29 lines (28 loc) · 837 Bytes
/
Q3.cpp
File metadata and controls
29 lines (28 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
using namespace std;
int main(){
char choice;
do{
int num;
cout << "Enter the integer from 1 to 10: ";
cin>>num;
if(num>10 || num <1){
cout << "Your number is invalid, Please enter a valid number";
continue;
}
for(int i = 1; i <= num; ++i) {
for(int j = 1; j <= i; ++j) {
cout << i;
}
cout << "\n";
}
do {
cout << "Do you want to generate another pattern? (Y/N): ";
cin >> choice;
if (choice != 'Y' && choice != 'y' && choice != 'N' && choice != 'n') {
cout << "Please enter 'Y' or 'N'."<<endl;
}
} while (choice != 'Y' && choice != 'y' && choice != 'N' && choice != 'n');
}
while(choice=='Y' || choice=='y');
}