Guest User

Untitled

a guest
Jan 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.88 KB | None | 0 0
  1. #include<iostream.h>
  2. #include<conio.h>
  3. int choice,choice2,if1,if2,ies1,ies2,ni1,ni2,nirem,nirem2,li,s,s1,s2,d1,d2,q1,q2,p1,p2,fl,wl,ctrfl,ctrwl,ctrdw,dw1,dw2,dws,dw;
  4. char let;
  5. void disp(),prob1(),prob2(),prob3(),prob4(),prob5(),sum(),diff(),quo(),prod(),prob6(),prob7(),prob8(),clear();
  6. main()
  7. {
  8. clrscr();
  9. cout<<"\n\t\t\t ---Adamson University---";
  10. cout<<"\n\t\t\t ---ITC Project in Finals---";
  11. cout<<"\n________________________________________________________________________________";
  12. disp();
  13. getch();
  14. return 0;
  15. }
  16. void disp()
  17. {
  18. cout<<"\n\n\nSelect a Program:";
  19. cout<<"\n\n0]To End the Program\n1]If Statement \n2]If Else \n3]Nested If \n4]Ladder If \n5]Mathematical Operators \n6]For Loop \n7]While Loop \n8]Do-While\n\n:";
  20. cin>>choice;
  21. switch(choice)
  22. {
  23. case 0:main;
  24. break;
  25. case 1:prob1();
  26. break;
  27. case 2:prob2();
  28. break;
  29. case 3:prob3();
  30. break;
  31. case 4:prob4();
  32. break;
  33. case 5:prob5();
  34. break;
  35. case 6:prob6();
  36. break;
  37. case 7:prob7();
  38. break;
  39. case 8:prob8();
  40. break;
  41. default:cout<<"\nEnter only Numbers 1-8";
  42. }
  43. }
  44. void null()
  45. {
  46. cout<<"\nWould You Like to try the other programs?(Y/N) :";
  47. cin>>let;
  48. switch(let)
  49. {
  50. case 'y':case'Y':clear();
  51. break;
  52. case 'n':case'N':clrscr();
  53. break;
  54. default:cout<<"\n\nEnter only Y or N";
  55. }
  56. }
  57. void prob1()
  58. {
  59. clrscr();
  60. cout<<"\nIf Statement:";
  61. cout<<"\nNormally,your program flows along line by line in the order in which it appears in your source code. The\nif statement enables you to test for a condtion (such as wheter two variables are equal) and branch\nto different parts of your code, depending on the result";
  62. cout<<"\n\nSyntax of If Statement:";
  63. cout<<"\nif(condition)";
  64. cout<<"\nstatement";
  65. cout<<"\n\nExample of a If Statement:";
  66. cout<<"\nEnter 1st Number:";
  67. cin>>if1;
  68. cout<<"\nEnter 2nd Number:";
  69. cin>>if2;
  70. if(if1<if2)
  71. cout<<"\n\nThe 2nd Number is Higher than the 1st number";
  72. null();
  73. }
  74. void prob2()
  75. {
  76. clrscr();
  77. cout<<"\nIf Else Statement:";
  78. cout<<"\nThe If Else Statement is Just Like If Statement the difference is we can additionally specfy what we \n want to do if the condition is not fulfilled using ELSE";
  79. cout<<"\n\nSyntax:";
  80. cout<<"\nif(condition)\n{\nstatement\n}\nelse\n{\nstatement\n}";
  81. cout<<"\n\nExample ofIf Else Statement:";
  82. cout<<"\nEnter 1st Number:";
  83. cin>>ies1;
  84. cout<<"\nEnter 2nd Number:";
  85. cin>>ies2;
  86. if(ies1>ies2)
  87. cout<<"\nThe 1st Number is Greater than the 2nd Number";
  88. else
  89. cout<<"\nThe 2nd Number is Greater than the 1st Number";
  90.  
  91. null();
  92. }
  93. void prob3()
  94. {
  95. clrscr();
  96. cout<<"\nNested If:";
  97. cout<<"\nIt is an If Statement within an If Statement";
  98. cout<<"\n\nSyntax:";
  99. cout<<"if(condition)\n{\nstatement\n\t{\n\tstatement\n\t}\n}";
  100. cout<<"\n\nExample of Nested If";
  101. cout<<"\nEnter 1st Number:";
  102. cin>>ni1;
  103. cout<<"\nEnter 2nd Number:";
  104. cin>>ni2;
  105. nirem=ni1%ni2;
  106. nirem2=nirem;
  107. if(ni1<ni2)
  108. {
  109. cout<<"\nThe 2nd number is greater than the 1st number";
  110. if(nirem==1)
  111. {
  112. cout<<"\nThe 2nd Number is Odd";
  113. if(nirem==0)
  114. {
  115. cout<<"\nThe 2nd Number is Even";
  116. }
  117. }
  118. }
  119. else if(ni1>ni2)
  120. {
  121. cout<<"\nThe 1st number is greater than the 2nd number";
  122. if(nirem2==1)
  123. {
  124. cout<<"\nThe 1st Number is Odd";
  125. if(nirem2==0)
  126. {
  127. cout<<"\nThe 1st Number is Even";
  128. }
  129. }
  130. }
  131. null();
  132. }
  133. void prob4()
  134. {
  135. clrscr();
  136. cout<<"\nLadder If/Else If:";
  137. cout<<"\nIt is like an If Else Statement that has more than 2 or more conditions";
  138. cout<<"\n\nSyntax:";
  139. cout<<"\nif(condition)\n{\nstatement\n}\nelse if(condition)\n{\nstatement\n}\nelse if(condition)\n{\nstatement\n}";
  140. cout<<"\n\nExample of Ladder if/Else if:";
  141. cout<<"\nEnter Your Grade Your Test Score:";
  142. cin>>li;
  143. if(li>=90)
  144. {
  145. cout<<"\nYour Grade is an A";
  146. }
  147. else if(li>=80 && li<90)
  148. {
  149. cout<<"\nYour Grade is a B";
  150. }
  151. else if(li>=70 && li<80)
  152. {
  153. cout<<"\nYour Grade is a C";
  154. }
  155. else if(li<=60 && li<70)
  156. {
  157. cout<<"\nYour Grade is a D";
  158. }
  159. null();
  160. }
  161. void prob5()
  162. {
  163. clrscr();
  164. cout<<"\nMathematical Operators:";
  165. cout<<"\nSelect an Operator:";
  166. cout<<"\n\t1]Addition \t\t 2]Subtraction \t\t 3]Division \t\t\t 4]Multiplication \t\t 0]Choose Other Programs\n\n:" ;
  167. cin>>choice2;
  168. switch(choice2)
  169. {
  170. case 0:clear();
  171. break;
  172. case 1:sum();
  173. break;
  174. case 2:diff();
  175. break;
  176. case 3:quo();
  177. break;
  178. case 4:prod();
  179. break;
  180. default:cout<<"\n\nEnter only Numbers 1-4";
  181. break;
  182. }
  183. }
  184. void sum()
  185. {
  186. cout<<"\nEnter 1st Number:";
  187. cin>>s1;
  188. cout<<"\nEnter 2nd Number:";
  189. cin>>s2;
  190. s=s1+s2;
  191. cout<<"\nThe Sum of the 2 Numbers is:"<<s<<"\n";
  192. cout<<"\n";
  193. null();
  194. }
  195. void diff()
  196. {
  197. cout<<"\nEnter 1st Number:";
  198. cin>>d1;
  199. cout<<"\nEnter 2nd Number:";
  200. cin>>d2;
  201. cout<<"\nThe difference of the 2 Numbers is:"<<d1-d2<<"\n";
  202. null();
  203. }
  204. void quo()
  205. {
  206. cout<<"\nEnter 1st Number:";
  207. cin>>q1;
  208. cout<<"Enter 2nd Number:";
  209. cin>>q2;
  210. cout<<"\nThe quotient of the 2 Numbers is:"<<q1/q2<<"\n";
  211. null();
  212. }
  213. void prod()
  214. {
  215. cout<<"\nEnter 1st Number:";
  216. cin>>p1;
  217. cout<<"\nEnter 2nd Number:";
  218. cin>>p2;
  219. cout<<"\nThe Product of the 2 Numbers is:"<<p1*p2<<"\n";
  220. null();
  221. }
  222. void prob6()
  223. {
  224. clrscr();
  225. cout<<"\nFor Loop:";
  226. cout<<"\nA Statemen Which Allows Code to be Repeatedly executed";
  227. cout<<"\n\nSyntax:";
  228. cout<<"\nfor(initial value;condition;action)\n{\nstatement\n}";
  229. cout<<"\n\nExample of For Loop:";
  230. cout<<"\nEnter a Number:";
  231. cin>>fl;
  232. for(ctrfl=1;ctrfl<=fl;ctrfl++){
  233. cout<<"\nAdamson University";
  234. }
  235. null();
  236. }
  237. void prob7()
  238. {
  239. clrscr();
  240. cout<<"\nWhile Loop:";
  241. cout<<"\nIt is like For Loop but in different syntax";
  242. cout<<"\n\nSyntax:";
  243. cout<<"\nwhile(condition)\n{\nstatement\n}";
  244. cout<<"\n\nExample of While Loop:";
  245. cout<<"\nEnter a Number:";
  246. cin>>wl;
  247. ctrwl=1;
  248. while(ctrw<wl)
  249. {
  250. cout<<"\nGo Falcons!";
  251. ctrwl=ctrwl++;
  252. }
  253. null();
  254. }
  255. void prob8()
  256. {
  257. clrscr();
  258. cout<<"\nDo-while Loop:";
  259. cout<<"\nA another way of Loop";
  260. cout<<"\n\nSyntax:";
  261. cout<<"\ndo\n{\nstatement\n}\nwhile(condition)";
  262. cout<<"\n\nExample of Do-while:";
  263. cout<<"\nHow Many times you want to print *?:";
  264. cin>>dw;
  265. do
  266. {
  267. cout<<"\n*";
  268. ctrdw=ctrdw++;
  269. }
  270. while(ctrdw<dw);
  271.  
  272. null();
  273. }
  274. void clear()
  275. {
  276. clrscr();
  277. disp();
  278. }
Add Comment
Please, Sign In to add comment