-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
222 lines (215 loc) · 6.23 KB
/
main.c
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<unistd.h>
void header()
{
system("cls");
//70 char
printf("***********************************************************************\n");
printf("**###################################################################**\n");
printf("**############################ Tool Box #############################**\n");
printf("**###################################################################**\n");
printf("***********************************************************************\n");
printf("** **\n");
}
void footers()
{
printf("** **\n");
}
void footer()
{
printf("**############### 0= Main Menu 999= Exit ###############**\n");
printf("***********************************************************************\n");
}
void drawrect(int w, int h)
{
int i, j;
h/=2;
putchar('\n');
for (i = 0; i < w; i++)
{
putchar('x');
}
putchar('\n');
for (i = 2; i < h; i++)
{
putchar('x');
for (j = 2; j < w; j++)
{
putchar(' ');
}
putchar('x');
putchar('\n');
}
for (i = 0; i < w; i++)
{
putchar('x');
}
putchar('\n');
putchar('\n');
}
int mod(char c[],int n)
{
int i,y = 0;
for(i=0; c[i]!='\0'; i++)
{
y = (y * 10 + c[i] - 48) % n;
}
return y;
}
void exits()
{
system("cls");
printf("******************************\n");
printf("******************************\n");
printf("******************************\n");
printf("******************************\n");
printf("******************************\n");
printf("******************************\n");
printf("********** Exiting ***********\n");
printf("******************************\n");
printf("******************************\n");
printf("******************************\n");
printf("******************************\n");
printf("******************************\n");
printf("******************************\n");
sleep(1);
}
void pyramid(int n)
{
system("cls");
printf("** Pyramid **\n");
footers();
printf("** 5= Go back 502= Reload **\n");
footer();
int i,a,j,k;
for(j=1; j<=n; j++)
{
k=n-j+1;
if(j<=9&&n>9)
{
k+=j;
}
else if(j>9){k+=n-j;}
for(k; k>=1; k--)
{
printf(" ");
}
for(i=j; i>0; i--)
{
printf("%d",i);
}
for(a=2; a<=j; a++)
{
printf("%d",a);
}
printf("\n");
}
}
void option(int x)
{
int a,b;
char c[1000];
switch(x)
{
case 0:
printf("** 1. Calculator 2. Tempeture Converstion **\n");
printf("** 3. Big Modulus 4. System Info **\n");
printf("** 5. Pattern 6. Geometry **\n");
footers();
footer();
break;
case 1:
printf("** 101. Addition 102. Substract **\n");
footers();
printf("** 0= Go back 1= Reload **\n");
footer();
break;
case 101:
printf("** Addition **\n");
footers();
printf("** 1= Go back 101= Reload **\n");
footer();
printf("Enter two numbers: ");
scanf("%d%d",&a,&b);
printf("Addition of the Two numbers: %d\n",a+b);
break;
case 2:
printf("** 201. Celsius 202. Fahrenheit **\n");
footers();
printf("** 0= Go back 2= Reload **\n");
footer();
break;
case 3:
printf("** Big Modulus **\n");
footers();
printf("** 0= Go back 3= Reload **\n");
footer();
printf("Enter number to modulus: ");
scanf("%s",c);
printf("Enter number to modulus with: ");
scanf("%d",&a);
printf("Answer: %d\n",mod(c,a));
break;
case 4:
system("cls");
system("systeminfo");
a=1;
do
{
printf("Enter 0 to exit: ");
scanf("%d",&a);
}
while(a!=0);
header();
x=0;
option(x);
break;
case 5:
printf("** 501. Rectangle 502. Pyramid **\n");
footers();
printf("** 0= Go back 5= Reload **\n");
footer();
break;
case 501:
printf("** Rectangle **\n");
footers();
printf("** 5= Go back 501= Reload **\n");
footer();
printf("Enter Width: ");
scanf("%d",&a);
printf("Enter Hight: ");
scanf("%d",&b);
drawrect(a,b);
break;
case 502:
printf("** Pyramid **\n");
footers();
printf("** 5= Go back 502= Reload **\n");
footer();
printf("Enter Hight: ");
scanf("%d",&a);
pyramid(a);
break;
}
}
int main()
{
int x=0;//option keyword
system("color 0A");
system("Title Tool Box");
while(1)
{
header();
option(x);
printf("Enter Option No.: ");
scanf("%d",&x);
if(x==999)
{
break;
}
}
exits();
}