Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream.h>
- #include<conio.h>
- 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;
- char let;
- void disp(),prob1(),prob2(),prob3(),prob4(),prob5(),sum(),diff(),quo(),prod(),prob6(),prob7(),prob8(),clear();
- main()
- {
- clrscr();
- cout<<"\n\t\t\t ---Adamson University---";
- cout<<"\n\t\t\t ---ITC Project in Finals---";
- cout<<"\n________________________________________________________________________________";
- disp();
- getch();
- return 0;
- }
- void disp()
- {
- cout<<"\n\n\nSelect a Program:";
- 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:";
- cin>>choice;
- switch(choice)
- {
- case 0:main;
- break;
- case 1:prob1();
- break;
- case 2:prob2();
- break;
- case 3:prob3();
- break;
- case 4:prob4();
- break;
- case 5:prob5();
- break;
- case 6:prob6();
- break;
- case 7:prob7();
- break;
- case 8:prob8();
- break;
- default:cout<<"\nEnter only Numbers 1-8";
- }
- }
- void null()
- {
- cout<<"\nWould You Like to try the other programs?(Y/N) :";
- cin>>let;
- switch(let)
- {
- case 'y':case'Y':clear();
- break;
- case 'n':case'N':clrscr();
- break;
- default:cout<<"\n\nEnter only Y or N";
- }
- }
- void prob1()
- {
- clrscr();
- cout<<"\nIf Statement:";
- 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";
- cout<<"\n\nSyntax of If Statement:";
- cout<<"\nif(condition)";
- cout<<"\nstatement";
- cout<<"\n\nExample of a If Statement:";
- cout<<"\nEnter 1st Number:";
- cin>>if1;
- cout<<"\nEnter 2nd Number:";
- cin>>if2;
- if(if1<if2)
- cout<<"\n\nThe 2nd Number is Higher than the 1st number";
- null();
- }
- void prob2()
- {
- clrscr();
- cout<<"\nIf Else Statement:";
- 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";
- cout<<"\n\nSyntax:";
- cout<<"\nif(condition)\n{\nstatement\n}\nelse\n{\nstatement\n}";
- cout<<"\n\nExample ofIf Else Statement:";
- cout<<"\nEnter 1st Number:";
- cin>>ies1;
- cout<<"\nEnter 2nd Number:";
- cin>>ies2;
- if(ies1>ies2)
- cout<<"\nThe 1st Number is Greater than the 2nd Number";
- else
- cout<<"\nThe 2nd Number is Greater than the 1st Number";
- null();
- }
- void prob3()
- {
- clrscr();
- cout<<"\nNested If:";
- cout<<"\nIt is an If Statement within an If Statement";
- cout<<"\n\nSyntax:";
- cout<<"if(condition)\n{\nstatement\n\t{\n\tstatement\n\t}\n}";
- cout<<"\n\nExample of Nested If";
- cout<<"\nEnter 1st Number:";
- cin>>ni1;
- cout<<"\nEnter 2nd Number:";
- cin>>ni2;
- nirem=ni1%ni2;
- nirem2=nirem;
- if(ni1<ni2)
- {
- cout<<"\nThe 2nd number is greater than the 1st number";
- if(nirem==1)
- {
- cout<<"\nThe 2nd Number is Odd";
- if(nirem==0)
- {
- cout<<"\nThe 2nd Number is Even";
- }
- }
- }
- else if(ni1>ni2)
- {
- cout<<"\nThe 1st number is greater than the 2nd number";
- if(nirem2==1)
- {
- cout<<"\nThe 1st Number is Odd";
- if(nirem2==0)
- {
- cout<<"\nThe 1st Number is Even";
- }
- }
- }
- null();
- }
- void prob4()
- {
- clrscr();
- cout<<"\nLadder If/Else If:";
- cout<<"\nIt is like an If Else Statement that has more than 2 or more conditions";
- cout<<"\n\nSyntax:";
- cout<<"\nif(condition)\n{\nstatement\n}\nelse if(condition)\n{\nstatement\n}\nelse if(condition)\n{\nstatement\n}";
- cout<<"\n\nExample of Ladder if/Else if:";
- cout<<"\nEnter Your Grade Your Test Score:";
- cin>>li;
- if(li>=90)
- {
- cout<<"\nYour Grade is an A";
- }
- else if(li>=80 && li<90)
- {
- cout<<"\nYour Grade is a B";
- }
- else if(li>=70 && li<80)
- {
- cout<<"\nYour Grade is a C";
- }
- else if(li<=60 && li<70)
- {
- cout<<"\nYour Grade is a D";
- }
- null();
- }
- void prob5()
- {
- clrscr();
- cout<<"\nMathematical Operators:";
- cout<<"\nSelect an Operator:";
- 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:" ;
- cin>>choice2;
- switch(choice2)
- {
- case 0:clear();
- break;
- case 1:sum();
- break;
- case 2:diff();
- break;
- case 3:quo();
- break;
- case 4:prod();
- break;
- default:cout<<"\n\nEnter only Numbers 1-4";
- break;
- }
- }
- void sum()
- {
- cout<<"\nEnter 1st Number:";
- cin>>s1;
- cout<<"\nEnter 2nd Number:";
- cin>>s2;
- s=s1+s2;
- cout<<"\nThe Sum of the 2 Numbers is:"<<s<<"\n";
- cout<<"\n";
- null();
- }
- void diff()
- {
- cout<<"\nEnter 1st Number:";
- cin>>d1;
- cout<<"\nEnter 2nd Number:";
- cin>>d2;
- cout<<"\nThe difference of the 2 Numbers is:"<<d1-d2<<"\n";
- null();
- }
- void quo()
- {
- cout<<"\nEnter 1st Number:";
- cin>>q1;
- cout<<"Enter 2nd Number:";
- cin>>q2;
- cout<<"\nThe quotient of the 2 Numbers is:"<<q1/q2<<"\n";
- null();
- }
- void prod()
- {
- cout<<"\nEnter 1st Number:";
- cin>>p1;
- cout<<"\nEnter 2nd Number:";
- cin>>p2;
- cout<<"\nThe Product of the 2 Numbers is:"<<p1*p2<<"\n";
- null();
- }
- void prob6()
- {
- clrscr();
- cout<<"\nFor Loop:";
- cout<<"\nA Statemen Which Allows Code to be Repeatedly executed";
- cout<<"\n\nSyntax:";
- cout<<"\nfor(initial value;condition;action)\n{\nstatement\n}";
- cout<<"\n\nExample of For Loop:";
- cout<<"\nEnter a Number:";
- cin>>fl;
- for(ctrfl=1;ctrfl<=fl;ctrfl++){
- cout<<"\nAdamson University";
- }
- null();
- }
- void prob7()
- {
- clrscr();
- cout<<"\nWhile Loop:";
- cout<<"\nIt is like For Loop but in different syntax";
- cout<<"\n\nSyntax:";
- cout<<"\nwhile(condition)\n{\nstatement\n}";
- cout<<"\n\nExample of While Loop:";
- cout<<"\nEnter a Number:";
- cin>>wl;
- ctrwl=1;
- while(ctrw<wl)
- {
- cout<<"\nGo Falcons!";
- ctrwl=ctrwl++;
- }
- null();
- }
- void prob8()
- {
- clrscr();
- cout<<"\nDo-while Loop:";
- cout<<"\nA another way of Loop";
- cout<<"\n\nSyntax:";
- cout<<"\ndo\n{\nstatement\n}\nwhile(condition)";
- cout<<"\n\nExample of Do-while:";
- cout<<"\nHow Many times you want to print *?:";
- cin>>dw;
- do
- {
- cout<<"\n*";
- ctrdw=ctrdw++;
- }
- while(ctrdw<dw);
- null();
- }
- void clear()
- {
- clrscr();
- disp();
- }
Add Comment
Please, Sign In to add comment