-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
117 lines (86 loc) · 2.57 KB
/
Copy pathmain.c
File metadata and controls
117 lines (86 loc) · 2.57 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
#include<ctype.h>
// #include<windows.h>
#include "patterns.h"
/*
! How to run
firs command: gcc main.c patterns.c -o program
second command : .\program
*/
int main(){
system("cls"); // clear the previous input
int choice = 0;
bool isexit = false;
bool iscorrectInput = true;
printf("=================================\n");
printf(" Welcome to Pattern Program\n");
printf(" Let's Generate Patterns\n");
printf("=================================\n\n");
while (!isexit){
printf(" Pattern's name:\n1.Triangle\n2.Reverse triangle.\n3.Pascal Triangle\n4.Pyramid\n5.Diamond\n6.Butterfly\n7.Circle\n8.Square\n ");
while(iscorrectInput){
printf("Enter your choice: ");
scanf("%d", &choice);
if (choice >=1 && choice<=8) {
iscorrectInput = false;
}else{
printf("\nInvalid choice. please try again!\n");
iscorrectInput = true;
choice = 0;
}
}
switch (choice)
{
case 1:
triangle();
break;
case 2:
reverse_triangle();
break;
case 3:
pascaltriangle();
break;
case 4:
pyramid();
break;
case 5:
diamond();
break;
case 6:
butterfly();
break;
case 7:
circle();
break;
case 8:
square();
break;
}
iscorrectInput = true;
int n = 0;
bool iscontinue = false;
while (!iscontinue){
printf("Do you want next pattern.\nif yes then enter 1 or no then enter 0: ");
scanf("%d", &n);
if (n == 1) {
printf("choose Your Next pattern :\n");
isexit = false;
iscontinue = true;
}
else if (n == 0){
printf("\n=======================================\n");
printf(" Thanks for using the patterns program\n");
printf("==========================================\n\n");
isexit = true;
iscontinue = true; // loop stop
}
else{
printf("Please enter 1 or 0 !\n");
}
}
}
return 0;
}