SlideShare a Scribd company logo
1 of 14
1 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y
Task 5:
//All_tasks.cpp
C++ program: gather all tasks
programmers
Prepared By:
Khalid Waleed
CANAL HIGHER INSTITUTE OF ENGINEERING & TECHNOLOGY
2 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y
1: // All_tasks.cpp
2: // gather all tasks programmers
3: #include <iostream>
4: #include <iomanip>
5: using namespace std;
6: void error(int &);
7: void line();
8: void sizes();
9: void numbers();
10: void factorial();
11: void daycalc();
12: int main()
13: {
14: int q; char Y;
15: do
16: {
17: line();
18: cout << setw(30)<<"khalid's projects"<< endl;
19: line();
20: cout <<"1- sizes.cpp"<< setw(25)<<"2- numbers.cpp"<<endl;
21: cout <<"3- factorial.cpp"<< setw(28)<<"4- daycalculation.cpp"<< endl;
22: line();
23: cout <<"Enter number of programme to open: ";
24: cin >> q;
25: error(q);
26: switch(q)
27: {
28: case 4:
29: cout << endl;
30: daycalc();
31: break;
32: case 1:
33: cout << endl;
34: sizes();
35: break;
36: case 2:
37: cout << endl;
38: numbers();
3 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y
39: break;
40: case 3:
41: cout << endl;
42: factorial();
43: break;
44: default:
45: cout<<"Unknown number!"<< 'n';
46: }
47: cout <<"openkhalid's projects (y/n)? :";
48: cin >> Y;
49: cout << endl;
50: }while(Y == 'y');
51: return 0;
52: }
53: void sizes()
54: {
55: int x;
56: cout <<"Size of bool"<< setw(11)<<":"<< setw(6)<< sizeof(bool)<<" Byte"<< endl;
57: cout <<"Size of char"<< setw(11)<<":"<< setw(6)<< sizeof(char)<<" Byte"<< endl;
58: cout <<"Size of unsigned char :"<< setw(6)<< sizeof(unsigned char)<<" Byte"<<
endl;
59: cout <<"Size of short"<< setw(10)<<":"<< setw(6)<< sizeof(short)<<" Byte"<< endl;
60: cout <<"Size of unsigned short:"<< setw(6)<< sizeof(unsigned short)<<" Byte"<<
endl;
61: cout <<"Size of long"<< setw(11)<<":"<< setw(6)<< sizeof(long)<<" Byte"<< endl;
62: cout <<"Size of unsigned long : "<< setw(5)<< sizeof(unsigned long)<<" Byte"<<
endl;
63: cout <<"Size of int"<< setw(12)<<":"<< setw(6)<< sizeof(int)<<" Byte"<< endl;
64: cout <<"Size of unsigned int"<< setw(3)<<":"<< setw(6)<< sizeof(unsigned int)<<"
Byte"<< endl;
65: cout <<"Size of short int"<< setw(6)<<":"<< setw(6)<< sizeof(short int)<<" Byte"<<
endl;
66: cout <<"Size of long int"<< setw(7)<<":"<< setw(6)<< sizeof(long int)<<" Byte"<<
endl;
67: cout <<"Size of float"<< setw(10)<<":"<< setw(6)<< sizeof(float)<<" Byte"<< endl;
68: cout <<"Size of double"<< setw(9)<<":"<< setw(6)<< sizeof(double)<<" Byte"<<
endl;
4 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y
69: cout <<"Size of long double"<< setw(4)<<":"<< setw(6)<< sizeof(long double)<<"
Byte"<< endl;
70: cout << endl <<"write any number to exit programme: ";
71: cin >> x;
72: error(x);
73: }
74: void numbers()
75: {
76: int process , numb , f=0;
77: char ask;
78: do{
79: cout <<" 1- ordering even numbers n 2- ordering odd numbers
80: n 3- ordering prime numbers";
81: cout <<"ninsert number of process : ";
82: cin >> process;
83: error(process);
84: switch(process)
85: {
86: case 1:
87: cout <<"n 4- desending order n 5- ascending order ";
88: cout <<"ninsert number of process :";
89: cin >> process;
90: error(process);
91: switch(process)
92: {
93: case 4:
94: cout <<"Enter your number : ";
95: cin >> numb;
96: error(numb);
97: for (numb ; numb>0;--numb)
98: {
99: if (numb%2==0)
100: {
101: cout << numb <<", ";
102: }
103: }
104: break;
105: case 5:
5 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y
106: cout <<"Enter your number : ";
107: cin >> numb;
108: error(numb);
109: for (int c=1; numb>=c ; c++)
110: {
111: if (c%2==0)
112: {
113: cout << c <<", ";
114: }
115: }
116: break;
117: default:
118: cout <<"number of process unknown !";
119: }
120: break;
121: case 2:
122: cout <<"n 6- desending order n 7- ascending order ";
123: cout <<"ninsert number of process : ";
124: cin >> process;
125: error(process);
126: switch(process)
127: {
128: case 6:
129: cout <<"Enter your number : ";
130: cin >> numb;
131: error(numb);
132: for (numb ; numb>0;--numb)
133: {
134: if (numb%2!=0)
135: {
136: cout << numb <<", ";
137: }
138: }
139: break;
140: case 7:
141: cout <<"Enter your number : ";
142: cin >> numb;
143: error(numb);
6 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y
144: for (int c=1; numb>=c ; c++)
145: {
146: if (c%2!=0)
147: {
148: cout << c <<", ";
149: }
150: }
151: break;
152: default:
153: cout <<"number of process unknown !";
154: }
155: break;
156: case 3:
157: cout <<"n 8- desending order n 9- ascending order ";
158: cout <<"ninsert number of process : ";
159: cin >> process;
160: error(process);
161: switch(process)
162: {
163: case 8:
164: cout <<"Enter your number : ";
165: cin >> numb;
166: error(numb);
167: for (numb ; numb>=2;--numb)
168: {
169: f=0;
170: for (int j=2; j<=numb/2; j++)
171: {
172: if (numb%j ==0)
173: {
174: f=1;
175: break;
176: }
177: }
178: if (f==0)
179: cout << numb <<", ";
180: }
181: break;
7 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y
182: case 9:
183: cout <<"Enter your number : ";
184: cin >> numb;
185: error(numb);
186: for ( int c=2; numb>=c ; c++)
187: {
188: f=0;
189: for (int j=2; j<=c/2; j++)
190: {
191: if (c % j ==0)
192: {
193: f=1;
194: break;
195: }
196: }
197: if (f==0)
198: cout << c <<", ";
199: }
200: break;
201: default:
202: cout <<"number of process unknown !";
203:
204: }
205: break;
206: default:
207: cout <<"number of process unknown !";
208: }
209: cout <<"nDo you want to exit the programme (y/n) ? ";
210: cin >> ask;
211: }while(ask == 'n');
212: }
213: void daycalc()
214: {
215: int day, month, m, year, century, day_of_week;
216: char ask;
217: cout << program to show the day of the week by date n";
218: line( );
219: cout <<"centuries availiable : 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23";
8 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y
220: cout <<"n ***** Note: we are now in the 21st century ***** n";
221: do
222: {
223: cout <<"please Enter the century number: ";
224: cin >> century;
225: error(century);
226: switch (century)
227: {
228: case20:
229: century;
230: break;
231: case21:
232: --century;
233: break;
234: case19:
235: century+=2;
236: break;
237: case18:
238: century++;
239: break;
240: case22:
241: century+=2;
242: break;
243: case23:
244: century+=2;
245: break;
246: case17:
247: century+=2;
248: break;
249: case16:
250: century+=3;
251: break;
252: case15:
253: century+=3;
254: break;
255: case14:
256: century-=2;
257: break;
9 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y
258: case13:
259: century--;
260: break;
261: default:
262: cout <<"century number not in the list n";
263: cout <<"Day calculation may not be accurate n";
264: cout <<"do you want to continue (y/n) ?";
265: cin >> ask;
266: if(ask == 'y')
267: break;
268: else
269: goto again;
270: }
271: cout <<"Enter the date (day/month/year) n";
272: cout <<"daynumber = "; cin >> day;
273: error(day);
274: if (day >31)
275: {
276: cout <<"Unknown day! n";
277: goto again;
278: }
279: cout <<"month number = "; cin >> month;
280: error(month);
281: switch(month)
282: {
283: case1:
284: m =6;
285: break;
286: case2:
287: m =2;
288: break;
289: case 3:
290: m =2;
291: break;
292: case4:
293: m =5;
294: break;
295: case5:
10 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y
296: m =0;
297: break;
298: case6:
299: m =3;
300: break;
301: case7:
302: m =5;
303: break;
304: case8:
305: m =1;
306: break;
307: case9:
308: m =4;
309: break;
310: case10:
311: m =6;
312: break;
313: case11:
314: m =2;
315: break;
316: case12:
317: m =4;
318: break;
319: default:
320: cout <<"Unknown month! n";
321: goto again;
322: }
323: cout <<"year number = "; cin >> year;
324: error(year);
325: day_of_week =( day + m + year +(year/4)+ century )%7;
326: switch(day_of_week)
327: {
328: case 6:
329: cout <<"the day was a Saturday n";
330: break;
331: case0:
332: cout <<"the day was a Sunday n";
333: break;
11 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y
334: case1:
335: cout <<"the day was a Monday n";
336: break;
337: case2:
338: cout <<"the day was a Tuesday n";
339: break;
340: case3:
341: cout <<"the day was a Wednesday n";
342: break;
343: case4:
344: cout <<"the day was a Thursday n";
345: break;
346: case5:
347: cout <<"the day was a Friday n";
348: break;
349: default:
350: cout <<"ERROR!! n";
351: }
352: again:
353: cout <<"Do you want to exit the programme (y/n)? : ";
354: cin >> ask;
355: }while(ask == 'n');
356: }
357: void error(int &x)
358: {
359: while (cin.fail())
360: {
361: cin.clear();// clear input buffer to restore cin to a usable state
362: cin.ignore(INT_MAX, 'n');// ignore last input
363: cout <<"You can only enter numbers.n";
364: cout <<"Enter a number : ";
365: cin >> x;
366: }
367: }
368: void line()
369: {
370: for(int j=0; j<45; j++)
371: cout << '=';
12 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y
372: cout << endl;
373: }
374: void factorial()
375: {
376: int c;
377: char ask;
378: do
379: {
380: long double j=1;
381: cout <<"Enter factorial number: ";
382: cin >> c;
383: error(c);
384: for( c ; c>0; c--)
385: {
386: j=j*c;
387: }
388: cout <<"!number = "<< j << endl;
389: cout <<"Do you want to exit the programme (y/n)? : ";
390: cin >> ask;
391: }while(ask == 'n');
392: }
13 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y
14 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y

More Related Content

What's hot

The Ring programming language version 1.4 book - Part 21 of 30
The Ring programming language version 1.4 book - Part 21 of 30The Ring programming language version 1.4 book - Part 21 of 30
The Ring programming language version 1.4 book - Part 21 of 30Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 59 of 88
The Ring programming language version 1.3 book - Part 59 of 88The Ring programming language version 1.3 book - Part 59 of 88
The Ring programming language version 1.3 book - Part 59 of 88Mahmoud Samir Fayed
 
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12THBANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12THSHAJUS5
 
Muhammad ariefnugraha 142014066_kode4
Muhammad ariefnugraha 142014066_kode4Muhammad ariefnugraha 142014066_kode4
Muhammad ariefnugraha 142014066_kode4Muhammad Nugraha
 
Static analysis and writing C/C++ of high quality code for embedded systems
Static analysis and writing C/C++ of high quality code for embedded systemsStatic analysis and writing C/C++ of high quality code for embedded systems
Static analysis and writing C/C++ of high quality code for embedded systemsAndrey Karpov
 
Programación de C++, Función Case
Programación de C++, Función CaseProgramación de C++, Función Case
Programación de C++, Función CaseRamon Lop-Mi
 
Rajeev oops 2nd march
Rajeev oops 2nd marchRajeev oops 2nd march
Rajeev oops 2nd marchRajeev Sharan
 
(Rx).NET' way of async programming (.NET summit 2017 Belarus)
(Rx).NET' way of async programming (.NET summit 2017 Belarus)(Rx).NET' way of async programming (.NET summit 2017 Belarus)
(Rx).NET' way of async programming (.NET summit 2017 Belarus)Stas Rivkin
 
Decipher Multi-Factor Authentication - A Developers Introduction
Decipher Multi-Factor Authentication - A Developers IntroductionDecipher Multi-Factor Authentication - A Developers Introduction
Decipher Multi-Factor Authentication - A Developers IntroductionArcBlock
 
The Ring programming language version 1.7 book - Part 81 of 196
The Ring programming language version 1.7 book - Part 81 of 196The Ring programming language version 1.7 book - Part 81 of 196
The Ring programming language version 1.7 book - Part 81 of 196Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 79 of 189
The Ring programming language version 1.6 book - Part 79 of 189The Ring programming language version 1.6 book - Part 79 of 189
The Ring programming language version 1.6 book - Part 79 of 189Mahmoud Samir Fayed
 
Stabilizer: Statistically Sound Performance Evaluation
Stabilizer: Statistically Sound Performance EvaluationStabilizer: Statistically Sound Performance Evaluation
Stabilizer: Statistically Sound Performance EvaluationEmery Berger
 

What's hot (19)

Vend with ff
Vend with ffVend with ff
Vend with ff
 
The Ring programming language version 1.4 book - Part 21 of 30
The Ring programming language version 1.4 book - Part 21 of 30The Ring programming language version 1.4 book - Part 21 of 30
The Ring programming language version 1.4 book - Part 21 of 30
 
The Ring programming language version 1.3 book - Part 59 of 88
The Ring programming language version 1.3 book - Part 59 of 88The Ring programming language version 1.3 book - Part 59 of 88
The Ring programming language version 1.3 book - Part 59 of 88
 
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12THBANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
 
cs8project
cs8projectcs8project
cs8project
 
Muhammad ariefnugraha 142014066_kode4
Muhammad ariefnugraha 142014066_kode4Muhammad ariefnugraha 142014066_kode4
Muhammad ariefnugraha 142014066_kode4
 
Static analysis and writing C/C++ of high quality code for embedded systems
Static analysis and writing C/C++ of high quality code for embedded systemsStatic analysis and writing C/C++ of high quality code for embedded systems
Static analysis and writing C/C++ of high quality code for embedded systems
 
Programación de C++, Función Case
Programación de C++, Función CaseProgramación de C++, Función Case
Programación de C++, Función Case
 
Rajeev oops 2nd march
Rajeev oops 2nd marchRajeev oops 2nd march
Rajeev oops 2nd march
 
Ip project
Ip projectIp project
Ip project
 
(Rx).NET' way of async programming (.NET summit 2017 Belarus)
(Rx).NET' way of async programming (.NET summit 2017 Belarus)(Rx).NET' way of async programming (.NET summit 2017 Belarus)
(Rx).NET' way of async programming (.NET summit 2017 Belarus)
 
Decipher Multi-Factor Authentication - A Developers Introduction
Decipher Multi-Factor Authentication - A Developers IntroductionDecipher Multi-Factor Authentication - A Developers Introduction
Decipher Multi-Factor Authentication - A Developers Introduction
 
The Ring programming language version 1.7 book - Part 81 of 196
The Ring programming language version 1.7 book - Part 81 of 196The Ring programming language version 1.7 book - Part 81 of 196
The Ring programming language version 1.7 book - Part 81 of 196
 
Main Form Number To Word
Main Form Number To WordMain Form Number To Word
Main Form Number To Word
 
Manual writer 3.0
Manual writer 3.0Manual writer 3.0
Manual writer 3.0
 
Numbers by singaraj
Numbers by singarajNumbers by singaraj
Numbers by singaraj
 
The Ring programming language version 1.6 book - Part 79 of 189
The Ring programming language version 1.6 book - Part 79 of 189The Ring programming language version 1.6 book - Part 79 of 189
The Ring programming language version 1.6 book - Part 79 of 189
 
Stabilizer: Statistically Sound Performance Evaluation
Stabilizer: Statistically Sound Performance EvaluationStabilizer: Statistically Sound Performance Evaluation
Stabilizer: Statistically Sound Performance Evaluation
 
CQL 实现
CQL 实现CQL 实现
CQL 实现
 

Similar to C++ program: All tasks .cpp

C++ program: Numbers .cpp
C++ program: Numbers .cppC++ program: Numbers .cpp
C++ program: Numbers .cppKhalid Waleed
 
C++ program: Day calculation .cpp
C++ program: Day calculation .cppC++ program: Day calculation .cpp
C++ program: Day calculation .cppKhalid Waleed
 
I have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdfI have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdfshreeaadithyaacellso
 
Microsoft Word Hw#1
Microsoft Word   Hw#1Microsoft Word   Hw#1
Microsoft Word Hw#1kkkseld
 
Sparse Matrix and Polynomial
Sparse Matrix and PolynomialSparse Matrix and Polynomial
Sparse Matrix and PolynomialAroosa Rajput
 
Chainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみたChainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみたAkira Maruoka
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical fileMitul Patel
 
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชันตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชันWarawut
 
C++ Programming - 4th Study
C++ Programming - 4th StudyC++ Programming - 4th Study
C++ Programming - 4th StudyChris Ohk
 
C++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerC++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerAndrey Karpov
 
Session05 iteration structure
Session05 iteration structureSession05 iteration structure
Session05 iteration structureHarithaRanasinghe
 
Detection of errors and potential vulnerabilities in C and C++ code using the...
Detection of errors and potential vulnerabilities in C and C++ code using the...Detection of errors and potential vulnerabilities in C and C++ code using the...
Detection of errors and potential vulnerabilities in C and C++ code using the...Andrey Karpov
 
lecture7.ppt
lecture7.pptlecture7.ppt
lecture7.pptEdFeranil
 
c++ project
c++ projectc++ project
c++ projectTrish004
 

Similar to C++ program: All tasks .cpp (20)

C++ program: Numbers .cpp
C++ program: Numbers .cppC++ program: Numbers .cpp
C++ program: Numbers .cpp
 
C++ program: Day calculation .cpp
C++ program: Day calculation .cppC++ program: Day calculation .cpp
C++ program: Day calculation .cpp
 
I have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdfI have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdf
 
Microsoft Word Hw#1
Microsoft Word   Hw#1Microsoft Word   Hw#1
Microsoft Word Hw#1
 
Sparse Matrix and Polynomial
Sparse Matrix and PolynomialSparse Matrix and Polynomial
Sparse Matrix and Polynomial
 
Chainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみたChainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみた
 
3. chapter ii
3. chapter ii3. chapter ii
3. chapter ii
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical file
 
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชันตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
 
C++ Programming - 4th Study
C++ Programming - 4th StudyC++ Programming - 4th Study
C++ Programming - 4th Study
 
project3
project3project3
project3
 
C++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerC++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical Reviewer
 
C++ file
C++ fileC++ file
C++ file
 
Session05 iteration structure
Session05 iteration structureSession05 iteration structure
Session05 iteration structure
 
2 d matrices
2 d matrices2 d matrices
2 d matrices
 
UNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptxUNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptx
 
Detection of errors and potential vulnerabilities in C and C++ code using the...
Detection of errors and potential vulnerabilities in C and C++ code using the...Detection of errors and potential vulnerabilities in C and C++ code using the...
Detection of errors and potential vulnerabilities in C and C++ code using the...
 
lecture7.ppt
lecture7.pptlecture7.ppt
lecture7.ppt
 
c++ project
c++ projectc++ project
c++ project
 
lecture56.ppt
lecture56.pptlecture56.ppt
lecture56.ppt
 

Recently uploaded

(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 

Recently uploaded (20)

DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 

C++ program: All tasks .cpp

  • 1. 1 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y Task 5: //All_tasks.cpp C++ program: gather all tasks programmers Prepared By: Khalid Waleed CANAL HIGHER INSTITUTE OF ENGINEERING & TECHNOLOGY
  • 2. 2 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y 1: // All_tasks.cpp 2: // gather all tasks programmers 3: #include <iostream> 4: #include <iomanip> 5: using namespace std; 6: void error(int &); 7: void line(); 8: void sizes(); 9: void numbers(); 10: void factorial(); 11: void daycalc(); 12: int main() 13: { 14: int q; char Y; 15: do 16: { 17: line(); 18: cout << setw(30)<<"khalid's projects"<< endl; 19: line(); 20: cout <<"1- sizes.cpp"<< setw(25)<<"2- numbers.cpp"<<endl; 21: cout <<"3- factorial.cpp"<< setw(28)<<"4- daycalculation.cpp"<< endl; 22: line(); 23: cout <<"Enter number of programme to open: "; 24: cin >> q; 25: error(q); 26: switch(q) 27: { 28: case 4: 29: cout << endl; 30: daycalc(); 31: break; 32: case 1: 33: cout << endl; 34: sizes(); 35: break; 36: case 2: 37: cout << endl; 38: numbers();
  • 3. 3 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y 39: break; 40: case 3: 41: cout << endl; 42: factorial(); 43: break; 44: default: 45: cout<<"Unknown number!"<< 'n'; 46: } 47: cout <<"openkhalid's projects (y/n)? :"; 48: cin >> Y; 49: cout << endl; 50: }while(Y == 'y'); 51: return 0; 52: } 53: void sizes() 54: { 55: int x; 56: cout <<"Size of bool"<< setw(11)<<":"<< setw(6)<< sizeof(bool)<<" Byte"<< endl; 57: cout <<"Size of char"<< setw(11)<<":"<< setw(6)<< sizeof(char)<<" Byte"<< endl; 58: cout <<"Size of unsigned char :"<< setw(6)<< sizeof(unsigned char)<<" Byte"<< endl; 59: cout <<"Size of short"<< setw(10)<<":"<< setw(6)<< sizeof(short)<<" Byte"<< endl; 60: cout <<"Size of unsigned short:"<< setw(6)<< sizeof(unsigned short)<<" Byte"<< endl; 61: cout <<"Size of long"<< setw(11)<<":"<< setw(6)<< sizeof(long)<<" Byte"<< endl; 62: cout <<"Size of unsigned long : "<< setw(5)<< sizeof(unsigned long)<<" Byte"<< endl; 63: cout <<"Size of int"<< setw(12)<<":"<< setw(6)<< sizeof(int)<<" Byte"<< endl; 64: cout <<"Size of unsigned int"<< setw(3)<<":"<< setw(6)<< sizeof(unsigned int)<<" Byte"<< endl; 65: cout <<"Size of short int"<< setw(6)<<":"<< setw(6)<< sizeof(short int)<<" Byte"<< endl; 66: cout <<"Size of long int"<< setw(7)<<":"<< setw(6)<< sizeof(long int)<<" Byte"<< endl; 67: cout <<"Size of float"<< setw(10)<<":"<< setw(6)<< sizeof(float)<<" Byte"<< endl; 68: cout <<"Size of double"<< setw(9)<<":"<< setw(6)<< sizeof(double)<<" Byte"<< endl;
  • 4. 4 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y 69: cout <<"Size of long double"<< setw(4)<<":"<< setw(6)<< sizeof(long double)<<" Byte"<< endl; 70: cout << endl <<"write any number to exit programme: "; 71: cin >> x; 72: error(x); 73: } 74: void numbers() 75: { 76: int process , numb , f=0; 77: char ask; 78: do{ 79: cout <<" 1- ordering even numbers n 2- ordering odd numbers 80: n 3- ordering prime numbers"; 81: cout <<"ninsert number of process : "; 82: cin >> process; 83: error(process); 84: switch(process) 85: { 86: case 1: 87: cout <<"n 4- desending order n 5- ascending order "; 88: cout <<"ninsert number of process :"; 89: cin >> process; 90: error(process); 91: switch(process) 92: { 93: case 4: 94: cout <<"Enter your number : "; 95: cin >> numb; 96: error(numb); 97: for (numb ; numb>0;--numb) 98: { 99: if (numb%2==0) 100: { 101: cout << numb <<", "; 102: } 103: } 104: break; 105: case 5:
  • 5. 5 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y 106: cout <<"Enter your number : "; 107: cin >> numb; 108: error(numb); 109: for (int c=1; numb>=c ; c++) 110: { 111: if (c%2==0) 112: { 113: cout << c <<", "; 114: } 115: } 116: break; 117: default: 118: cout <<"number of process unknown !"; 119: } 120: break; 121: case 2: 122: cout <<"n 6- desending order n 7- ascending order "; 123: cout <<"ninsert number of process : "; 124: cin >> process; 125: error(process); 126: switch(process) 127: { 128: case 6: 129: cout <<"Enter your number : "; 130: cin >> numb; 131: error(numb); 132: for (numb ; numb>0;--numb) 133: { 134: if (numb%2!=0) 135: { 136: cout << numb <<", "; 137: } 138: } 139: break; 140: case 7: 141: cout <<"Enter your number : "; 142: cin >> numb; 143: error(numb);
  • 6. 6 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y 144: for (int c=1; numb>=c ; c++) 145: { 146: if (c%2!=0) 147: { 148: cout << c <<", "; 149: } 150: } 151: break; 152: default: 153: cout <<"number of process unknown !"; 154: } 155: break; 156: case 3: 157: cout <<"n 8- desending order n 9- ascending order "; 158: cout <<"ninsert number of process : "; 159: cin >> process; 160: error(process); 161: switch(process) 162: { 163: case 8: 164: cout <<"Enter your number : "; 165: cin >> numb; 166: error(numb); 167: for (numb ; numb>=2;--numb) 168: { 169: f=0; 170: for (int j=2; j<=numb/2; j++) 171: { 172: if (numb%j ==0) 173: { 174: f=1; 175: break; 176: } 177: } 178: if (f==0) 179: cout << numb <<", "; 180: } 181: break;
  • 7. 7 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y 182: case 9: 183: cout <<"Enter your number : "; 184: cin >> numb; 185: error(numb); 186: for ( int c=2; numb>=c ; c++) 187: { 188: f=0; 189: for (int j=2; j<=c/2; j++) 190: { 191: if (c % j ==0) 192: { 193: f=1; 194: break; 195: } 196: } 197: if (f==0) 198: cout << c <<", "; 199: } 200: break; 201: default: 202: cout <<"number of process unknown !"; 203: 204: } 205: break; 206: default: 207: cout <<"number of process unknown !"; 208: } 209: cout <<"nDo you want to exit the programme (y/n) ? "; 210: cin >> ask; 211: }while(ask == 'n'); 212: } 213: void daycalc() 214: { 215: int day, month, m, year, century, day_of_week; 216: char ask; 217: cout << program to show the day of the week by date n"; 218: line( ); 219: cout <<"centuries availiable : 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23";
  • 8. 8 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y 220: cout <<"n ***** Note: we are now in the 21st century ***** n"; 221: do 222: { 223: cout <<"please Enter the century number: "; 224: cin >> century; 225: error(century); 226: switch (century) 227: { 228: case20: 229: century; 230: break; 231: case21: 232: --century; 233: break; 234: case19: 235: century+=2; 236: break; 237: case18: 238: century++; 239: break; 240: case22: 241: century+=2; 242: break; 243: case23: 244: century+=2; 245: break; 246: case17: 247: century+=2; 248: break; 249: case16: 250: century+=3; 251: break; 252: case15: 253: century+=3; 254: break; 255: case14: 256: century-=2; 257: break;
  • 9. 9 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y 258: case13: 259: century--; 260: break; 261: default: 262: cout <<"century number not in the list n"; 263: cout <<"Day calculation may not be accurate n"; 264: cout <<"do you want to continue (y/n) ?"; 265: cin >> ask; 266: if(ask == 'y') 267: break; 268: else 269: goto again; 270: } 271: cout <<"Enter the date (day/month/year) n"; 272: cout <<"daynumber = "; cin >> day; 273: error(day); 274: if (day >31) 275: { 276: cout <<"Unknown day! n"; 277: goto again; 278: } 279: cout <<"month number = "; cin >> month; 280: error(month); 281: switch(month) 282: { 283: case1: 284: m =6; 285: break; 286: case2: 287: m =2; 288: break; 289: case 3: 290: m =2; 291: break; 292: case4: 293: m =5; 294: break; 295: case5:
  • 10. 10 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y 296: m =0; 297: break; 298: case6: 299: m =3; 300: break; 301: case7: 302: m =5; 303: break; 304: case8: 305: m =1; 306: break; 307: case9: 308: m =4; 309: break; 310: case10: 311: m =6; 312: break; 313: case11: 314: m =2; 315: break; 316: case12: 317: m =4; 318: break; 319: default: 320: cout <<"Unknown month! n"; 321: goto again; 322: } 323: cout <<"year number = "; cin >> year; 324: error(year); 325: day_of_week =( day + m + year +(year/4)+ century )%7; 326: switch(day_of_week) 327: { 328: case 6: 329: cout <<"the day was a Saturday n"; 330: break; 331: case0: 332: cout <<"the day was a Sunday n"; 333: break;
  • 11. 11 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y 334: case1: 335: cout <<"the day was a Monday n"; 336: break; 337: case2: 338: cout <<"the day was a Tuesday n"; 339: break; 340: case3: 341: cout <<"the day was a Wednesday n"; 342: break; 343: case4: 344: cout <<"the day was a Thursday n"; 345: break; 346: case5: 347: cout <<"the day was a Friday n"; 348: break; 349: default: 350: cout <<"ERROR!! n"; 351: } 352: again: 353: cout <<"Do you want to exit the programme (y/n)? : "; 354: cin >> ask; 355: }while(ask == 'n'); 356: } 357: void error(int &x) 358: { 359: while (cin.fail()) 360: { 361: cin.clear();// clear input buffer to restore cin to a usable state 362: cin.ignore(INT_MAX, 'n');// ignore last input 363: cout <<"You can only enter numbers.n"; 364: cout <<"Enter a number : "; 365: cin >> x; 366: } 367: } 368: void line() 369: { 370: for(int j=0; j<45; j++) 371: cout << '=';
  • 12. 12 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y 372: cout << endl; 373: } 374: void factorial() 375: { 376: int c; 377: char ask; 378: do 379: { 380: long double j=1; 381: cout <<"Enter factorial number: "; 382: cin >> c; 383: error(c); 384: for( c ; c>0; c--) 385: { 386: j=j*c; 387: } 388: cout <<"!number = "<< j << endl; 389: cout <<"Do you want to exit the programme (y/n)? : "; 390: cin >> ask; 391: }while(ask == 'n'); 392: }
  • 13. 13 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y
  • 14. 14 | P a g e C A N A L H I G H E R I N S T I T U T E O F E N G I N E E R I N G & T E C H N O L O G Y