วันศุกร์ที่ 18 กันยายน พ.ศ. 2552

unit 1-6 รวม

#include
#include
#include
#include
float sum57(float arg1,float arg2);
float multiply57(float&arg3,float&arg4);
float arg1,arg2,arg3,arg4 ;
void line58();
void line58(int x58);
void line58(char ch58,int x58);
void line58(char ch58);
void line59(char ch59='_',int x59=80);
void line510();
void repeat510();
int x510;
int y510;
template
TYPE sum511(TYPE first,TYPE second)
{
return first+second;
}
template
New_type multiply511(New_type number511,New_type number512)
{
return number511*number512;
}
main()
{
int ch;
do
{
clrscr();

cout<<"\n Program By : pratya wutticho "<cout<<" No : 8 "<cout<<"\n*********************************";
cout<<"\n Work ";
cout<<"\n---------------------------------";
cout<<"\n";
cout<<" [1] Unit 1 \n";
cout<<" [2] Unit 2 \n";
cout<<" [3] Unit 3 \n";
cout<<" [4] Unit 4 \n";
cout<<" [5] Unit 5 \n";
cout<<" [6] Unit 6 \n";
cout<<" [0] Exit \n";
cout<<"---------------------------------\n";
cout<<"Please Select 1-6 = ";
cin>>ch;
switch(ch)
{
case 1 :
int ch1;
do
{
clrscr();
cout<<"\n Program By : pratya wutticho "<cout<<" No : 8 "<cout<<"************************************\n"<cout<<" Unit 1 "<cout<<" [1] Page 5 "<cout<<" [2] Page 12 "<cout<<" [3] Page 13 "<cout<<" [4] Page 14 "<cout<<" [5] Page 15 "<cout<<" [6] Page 16 "<cout<<" [7] Page 17 "<cout<<" [8] Page 20 "<cout<<" [9] Page 21_1 "<cout<<" [10] Page 21_3 "<cout<<" [0] Back To Manu \n "<cout<<"************************************"<cout<<"\nPlease Select [0-10] : ";
cin>>ch1;
switch(ch1)
{
case 1 :clrscr();
cout<<"\n Program By : pratya wutticho "<cout<<" No : 8 "<cout<<"Office : Computer Department,RIPA";
getch();
break;
case 2 :clrscr();
cout<<"Size of char = "<cout<<"Size of unsigned char = "<cout<<"Size of int = "<cout<<"Size of unsigned int = "<cout<<"Size of short int = "<cout<<"Size of long = "<cout<<"Size of unsigned long = "<cout<<"Size of float = "<cout<<"Size of double = "<cout<<"Size of long double = "<getch();
break;
case 3 :float sale,price;
clrscr();
sale = 500.25;
price = 5.25;
float total = sale*price;
cout<<"Total Sale = "< getch();
break;
case 4 :int number1;
float sales1,purchase1;
//set value of variable
number1 = 50;
sales1 = 5000.75;
purchase1 = 3500.50;
clrscr();
//show varlue from variable
cout<<"show varlue of variable"<cout<<"number ="<cout<<"sales ="<cout<<"purchase ="<getch();
break;
case 5 :int number2 = 500; //declaration and set value variable
float sales2 = 500.50, purchase2 = 3500.75;//declaration and set value variable
clrscr();//function clear screen from
//show varlue from variable
cout<<"show varlue of variable"<cout<<"number ="<cout<<"sales ="<cout<<"purchase ="<getch();
break;
case 6 :int grade1,midterm1,final1,total1;//define globaland locat variable in function main() local
clrscr();
midterm1=30;
final1=50;
total1=midterm1+final1 ;
grade1 ='A';
cout<<"You get total scare"<cout<<"\n";
cout<<"\n Program By : pratya wutticho "<cout<<" No : 8 "<cout<<"\n";
cout<<"------------------------------\n";
cout<<"\n";
cout<<"Display Logic Operation:\a";
cout<<"\nLogic value of expression(3==5) : "<<(3==5);
cout<<"\nLogic value of expression(5==5) : "<<(5==5);
cout<<"\nLogic value of expression(3<=5) : "<<(3<=5);
cout<<"\nLogic value of expression(3>=5) : "<<(3>=5);
cout<<"\nLogic value of expression(3<=5)&&(5>3) : "<<((3<=5)&&(5>3));
cout<<"\nLogic value of expression((3<=5)&&(3>5)) : "<<((3<=5)&&(3>5));
cout<<"\nLogic value of expression((3<=5)(3>5)) : "<<((3<=5)(3>5));
cout<<"\nLogic value of expression((8<=5)(3>=5)) : "<<((8<=5)(3>=5));
cout<<"\n\nValue 1 is true,0 is false ...press any key";
getch();
break;
case 9 :int A1=50,B1=30,C1=5,D1=3,E1=10;
clrscr();
cout<<"------------------------------\n";
cout<<"\n";
cout<<"\n Program By : pratya wutticho "<cout<<" No : 8 "<cout<<"\n";
cout<<"------------------------------\n";
cout<<"\n";
cout<<"1.1 (A+B)*(E-D) = "<<(A1+B1)*(E1-D1);
cout<<"\n\n1.2 ++D+C*E = "<<++D1+C1*E1;
cout<<"\n\n1.3 (25+A)/C+B = "<<(25+A1)/C1+B1;
cout<<"\n\n1.4 A*-D = "<cout<<"\n\n1.5 20*C+B+++D/2 = "<<20*C1+B1+++D1/2;
cout<<"\n\n1.6 --D+C+B-- = "<<--D1+C1+B1--;
cout<<"\n\n1.7 25*D/5+10 = "<<25*D1/5+10;
cout<<"\n\n1.8 A+B--+D = "<cout<<"\n\n1.9 C*2+E*5 = "<cout<<"\n\n1.10 (A*2)+B/C-15 = "<<(A1*2)+B1/C1-15;

cout<<"\n\n------------------------------\n";
getch();
break;
case 10 :int A2=20,B2=30,C2=2,D2=5,E2=50;
clrscr();
cout<<"------------------------------\n";
cout<<"\n";
cout<<"\n Program By : pratya wutticho "<cout<<" No : 8 "<cout<<"\n";
cout<<"------------------------------\n";
cout<<"\n";
cout<<"Display Logic Operation:\a";
cout<<"\n3.1 Logic value of expression (A>=B)&&(A==A) : "<<(A2>=B2)&&(A2==A2);
cout<<"\n3.2 Logic value of expression (B+C>A+D)(B+CA2+D2)(B2+C2cout<<"\n3.3 Logic value of expression (A==20)&&(B>=30) : "<<(A2==20)&&(B2>=30);
cout<<"\n3.4 Logic value of expression (50==E)(!(D<=E)) : "<<(50==E2)(!(D2<=E2));
cout<<"\n3.5 Logic value of expression !(D!=5) : "<cout<<"\n3.6 Logic value of expression (B+C+20)!=50 : "<<((B2+C2+20)!=50);
cout<<"\n3.7 Logic value of expression C==(D-3) : "<<(C2==(D2-3));
cout<<"\n3.8 Logic value of expression (A/C<=B)&&(C+D<=A)(D>A) : "<<(A2/C2<=B2)&&(C2+D2<=A2)(D2>A2);
cout<<"\n3.9 Logic value of expression (A%C+5)==(E/5-10) : "<<((A2%C2+5)==(E2/5-10));
cout<<"\n3.10 Logic value of expression (Acout<<"\n\nValue 1 is true,0 is false ...press any key";
getch();
break;
}//end of do...while
}//end of switch
while(ch1!=0);
break;
case 2 :
int ch2;
do
{
clrscr();
cout<<"\n Program By : pratya wutticho "<cout<<" No : 8 "<cout<<"************************************\n"<cout<<" Unit 2 "<cout<<" [1] Cout_exp.CPP "<cout<<" [2] Cout_exp2.CPP "<cout<<" [3] Endl_exp.CPP "<cout<<" [4] Setw.CPP "<cout<<" [5] Coutmat.CPP "<cout<<" [6] Set_dec.CPP "<cout<<" [7] Func_Mat.CPP "<cout<<" [8] Escape.CPP "<cout<<" [9] Area_cir.CPP "<cout<<" [10] Cin_cont.CPP "<cout<<" [11] Base_mun.CPP "<cout<<" [0] Back To Manu \n"<cout<<"************************************"<cout<<"\nPlease Select [0-11] : ";
cin>>ch2;
switch(ch2)
{
case 1 :
clrscr();
cout<<"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n";
cout<<"\n";
cout<<"\n Program By : pratya wutticho "<cout<<" No : 8 "<cout<<"\n";
cout<<"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n";
cout<<"\n";
cout<<"This is Turbo C++Program";
cout<<"C++ is hight language";
getch();
break;
case 2 :
clrscr();
cout<<"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n";
cout<<"\n";
cout<<"\n Program By : pratya wutticho "<cout<<" No : 8 "<cout<<"\n";
cout<<"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n";
cout<<"\n";
cout<<"This is Turbo C++Program."<<" "<<" It is very easy.";
cout<<"I love C++."<<" "<<" It's high level language.";
getch();
break;
case 3 :
clrscr(); //clear screen standard function form conio.h
cout<<"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n";
cout<<"\n";
cout<<"\n Program By : pratya wutticho "<cout<<" No : 8 "<cout<<"\n";
cout<<"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n";
cout<<"\n";
cout<<"This is Turbo C++Progarm"<cout<<"It is very easy."<cout<cout<<"I like C++Program"<cout<<"Press any key to continue..."<getch(); //get character standard function form conio.h
break;
case 4 :
clrscr(); //clear screen standard function form conio.h
cout<<"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n";
cout<<"\n";
cout<<"\n Program By : pratya wutticho "<cout<<" No : 8 "<cout<<"\n";
cout<<"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n";
cout<<"\n";
cout<cout<cout<cout<cout<getch(); //get character standara function form conio.h
break;
case 5 :
int number4,number5;
float x4,y4,z4 ;
//set value of variable
number4=20;
number5=30;
x4=25.25;y4=30.05;z4=10.75;
//display calculation result
clrscr();
cout<<"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n";
cout<<"\n";
cout<<"\n Program By : pratya wutticho "<cout<<" No : 8 "<cout<<"\n";
cout<<"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n";
cout<<"\n";
cout<<"Program Display Mathmetic calculation"<cout<<"\n";
cout<<"number1="<cout<<"\n";
cout<<"number2="<cout<<"\n";
cout<<"number1+number2="<cout<<"\n";
cout<<"number1-number2="<cout<<"\n";
cout<<"x+y+z="<cout<<"\n";
cout<<"x*y*z="<cout<<"\n";
cout<<"50*25*12.5="<<50*25*12.5<getch();
break;
case 6 :
float A5=125.25125;
float B5=10.7525;
float C5=212.15;
clrscr(); //function in conio.h for clear screen
cout<<"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n";
cout<<"\n";
cout<<"\n Program By : pratya wutticho "<cout<<" No : 8 "<cout<<"\n";
cout<<"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n";
cout<<"\n";
cout<<"Display set precision of float number..."<cout<<"\n";
cout<<"A+B+"<cout<<"\n";
cout<<"A*B*C="<cout<<"\n";
cout<<"A*B="<cout<<"\n";
cout<<"A+B+C="<cout<<"\n";
cout<<"A+B+C="<cout<<"\n";
cout<<"A/B="<getch();
break;
case 7 :
double x6=9.0 ,y6=2.0;
clrscr();
cout<<"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n";
cout<<"\n";
cout<<"\n Program By : pratya wutticho "<cout<<" No : 8 "<cout<<"\n";
cout<<"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n";
cout<<"\n";
cout<<"Display useing mathmetic functions...\a"<cout<getch();
break;
case 8 :
clrscr();//clear screen
int number6,ch6,number7;
cout<<"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n";
cout<<"\n";
cout<<"\n Program By : pratya wutticho "<cout<<" No : 8 "<cout<<"\n";
cout<<"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n";
cout<<"\n";
cout<<"Hello Program C++"<<'\n';//new line
cin>>number6; //enter inter from keyboard
cout<<"\nEnter 1 character :";
cin>>ch6;//enter 1 character from keyboard
cout<<"\n\nPress any key to display...";
getch();//wait press any key
clrscr();
//Program display value from variable
cout<<"You enter number and character :\n\a";
cout<<"Value of number 1 :"<cout<<"\nValue of number 2 :"<cout<<"\nValue of character :"<cout<<"\n\nPress any key to exit..." ;
getch();
break;
case 9 :
float rad; //declared real variable
const float PI= 3.14159; // defined constant PI
//start statement
clrscr();
cout<<"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n";
cout<<"\n";
cout<<"\n Program By : pratya wutticho "<cout<<" No : 8 "<cout<<"\n";
cout<<"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n";
cout<<"\n";
cout<< "Please enter radius of circle : ";
cin>>rad;
float area = PI*rad*rad;//declarad variable at position that want to use
cout<<"\n\nRadius of circle = "<cout<<"\n\nArea of circles = \a\n"<getch();
break;
case 10 :
int numbera,numberb,numberc;//declared 3 integer variable
//start startment
clrscr();
cout<<"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n";
cout<<"\n";
cout<<"\n Program By : pratya wutticho "<cout<<" No : 8 "<cout<<"\n";
cout<<"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n";
cout<<"\n";
cout<<" Please enter 3 integer number :\n ";
cin>> numbera,numberb,numberc;//enter 3 amount integer from keyboard
cout<<"\nPress any key to display.... " ;
getch();
clrscr();
//process display value from variable
cout<<"You enter 3 number: \n\a";
cout<<"Value of number1 :\n"<cout<<"Value of number2: \n"<cout<<"Value of number3 :\n"<cout<<"Press any key to exit...\n" ;
getch();//wait press any key
break;
case 11 :
clrscr();
cout<<"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n";
cout<<"\n";
cout<<"\n Program By : pratya wutticho "<cout<<" No : 8 "<cout<<"\n";
cout<<"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n";
cout<<"\n";
cout<< "Display change base number ..."<cout<<"\n";
cout<< "10 decimal to hexadecimal = "<cout<<"\n";
cout<< "5865 decimal to hexadecimal = " <cout<<"\n";
cout<< "1250 decimal to octal = "<cout<<"\n";
cout<< "02342 octal to decimal = "<cout<<"\n";
cout<< "0xabc 125 hexadecimal to decimal = "<cout<<"\n";
cout<< "0xf hexadecimal to decimal = "<getch();
break;
}//end of do...while
}//end of switch
while(ch2!=0);
break;
case 3 :
int ch3;
do
{
clrscr();
cout<<"\n Program By : pratya wutticho "<cout<<" No : 8 "<cout<<"************************************\n"<cout<<" Unit 3 "<cout<<" [1] Page 34_1 "<cout<<" [2] Page 34_2 "<cout<<" [3] Page 36_1 "<cout<<" [4] Page 36_2 "<cout<<" [5] Page 38 "<cout<<" [6] Page 39 "<cout<<" [7] Page 41 "<cout<<" [0] Back To Manu \n "<cout<<"************************************"<cout<<"\nPlease Select : [0-7] = ";
cin>>ch3;
switch(ch3)
{
case 1 :
int x33,y33;
int result33 =100;// start statement
clrscr();
cout<<"Please enter integer number : \n";
cout<<"\nFirst number : ";
cin>>y33;
cout<<"\nSecond number : ";
cin>>x33;
//condition of if
if(x33>y33)//condtition
cout<<"\nFirst number is greater than second numbre \a\n";
if(x33+y33>result33)//condition
cout<<"\nFirst number+Seconde number is greater than \a\n"<getch();
break;
case 2 :
int x44,y44;
int result44 = 100;
//start statement
clrscr();
cout<<"Please enter integer number : ";
cin>>x44;
cout<<"\nSecond number : ";
cin>>y44;
//condition of if
if (x44>y44)
{
clrscr();
cout<<"\nFirst number is :"<cout<<"\nSecond number is :"<cout<<"\nFirst number is greater than second number\a\n";
}
if(x44+y44<=result44)
{
clrscr();
cout<<"\nFirst number is :"<cout<<"\nSecond number is :"<cout<<"\nFirst number + Seconde number <=\a\n"<}
getch();
break;
case 3 :
int x55,y55;
//start statement
clrscr();
cout<<"Please enter integer number : \n";
cout<<"\nFirst number:";
cin>>x55;
cout<<"\nSecond number :";
cin>>y55;
if(x55,y55)//condition of if
cout<<"\nFirst number is greater than second number\a\n";
else
cout<<"\nSecond number is greater than or equal first number\a\n";
getch();
break;
case 4 :
int x66,y66;
//start statement
clrscr();
cout<<"Please enter integer number :\n";
cout<<"\nFirst number:";
cin>>x66;
cout<<"\nSecond number:" ;
cin>>y66;
//condition of if
if (x66>y66)
{clrscr();
cout<<"You enter 2 number:";
cout<<"\nFirst number is:"<cout<<"\nSecond number is:"<cout<<"\nFirst number is great than second number \a\n";
getch();
}
else
{
clrscr();
cout<<"You enter 2 number : ";
cout<<"\nFirst number is : ";
cout<<"\nSecond number is :" ;
cout<<"\nSecond number is greater than or equal first number \a\n" ;
}
getch();
break;
case 5 :
int score77;
char grade77;
//begin statement
clrscr();
cout<<"Program calculate grade";
cout<<"\n\nPlease enter your score :";
cin>>score77; //input score
if(score77<0)//calculate grade use if...else if..
grade77='*';
else if(score77<=49)
grade77='F';
else if(score77<=59)
grade77='D';
else if(score77<=69)
grade77='C';
else if(score77<=79)
grade77='B';
else if(score77<=100)
grade77='A';
else
grade77='*';
cout<<"\nYou get grade : \a"<if(grade77=='*')
cout<<"Your score = "<getch();
break;
case 6 :
int score88;
char grade88;
//begin statement
clrscr();
cout<<"Program calculate grade";
cout<<"\n\nPlease enter your score :";
cin>>score88; //input score
//calculate grade use if...else if..
if(score88<0score88>100)//check enter error score
grade88='*';
else if(score88>=0&&score88<=49)
grade88='F';
else if(score88>=50&&score88<=59)
grade88='D';
else if(score88>=60&&score88<=69)
grade88='C';
else if(score88>=70&&score88<=79)
grade88='B';
else
grade88='A'; //end of if command
cout<<"\nYou get grade : \a"<if(grade88=='*')
cout<<"Your score = "<getch();
break;
case 7 :
int first99,second99;
char choice99;
//begin statement
clrscr();
cout<<"Program calculate Area\n";
cout<<"1.Circle\n";
cout<<"2.Square\n";
cout<<"3.Triangle\n";
cout<<"Please select your choice <1-3> : ";
cin>>choice99;
//begin statement
switch(choice99)
{
case'1':
cout<<"\nYou select choice "< cout<<"Press any key to end program\n";
break;
case'2':
cout<<"\nYou select choice "< cout<<"Press any key to end program\n";
break;
case'3':
cout<<"\nYou select choice "< cout<<"Press any key to end program\n";
break;
default:
cout<<"\nYou select Another choice \a\a\n";
cout<<"Press any key to end program\n";
}
getch();
break;
}//end of do...while
}//end of switch
while(ch3!=0);
break;
case 4:
int ch4;
do
{
clrscr();
cout<<"\n Program By : pratya wutticho "<cout<<" No : 8 "<cout<<"************************************\n"<cout<<" Unit 4 "<cout<<" [1] For_exp1.CPP "<cout<<" [2] For_exp2.CPP "<cout<<" [3] For_exp3.CPP "<cout<<" [4] For_exp4.CPP "<cout<<" [5] While1.CPP "<cout<<" [6] While2.CPP "<cout<<" [7] While3.CPP "<cout<<" [8] Dowhile1.CPP "<cout<<" [9] Dowhile2.CPP "<cout<<" [10] Break.CPP "<cout<<" [11} Continue.CPP "<cout<<" [0] Back To Manu \n "<cout<<"************************************"<cout<<"\nPlease Select [0-10] : ";
cin>>ch4;
switch(ch4)
{
case 1 :
int i44;
clrscr();
for(i44=1;i44>=5;i44++)//set iniatial i value and condition of for loop
cout<<"Program C++\n";
getch();cout<<'\n';
//condition with decrease value i=i-1
for(i44=5;i44>=1;i44--)
cout<<"I love C++ language\n";
getch();cout<<'\n';
for(i44=16;i44<=20;i44++)
cout<<"C++ language is very easy for me \n" ;
getch();
break;
case 2 :
float average44,i41,summation44;
//begin statement
clrscr();
summation44=0;
average44=0;
//set initial value
cout<<"Progarm display summation and average 1-10\n";
for(i41=1;i41<=10;i41++)
{cout<summation44=summation44+i41;//calculate summation1-10
}
average44=summation44/10;
cout<<"\n Summation 1-10="<cout<<"\n Average 1-10"<getch();
break;
case 3 :
float i42,summation42,n42;
float average42;
//begin statement
clrscr();
summation42=0;average42=0; //set initial value
cout<<"Program display summation and average 1-n\n";
cout<<"Please enter n : ";
cin>>n42;
for(i42=1;i42<=n42;i42++);
{
cout<summation42=summation42+i42; //calculate summation 1-10
}
average42=summation42/n42;
cout<<"\nSummation 1-10 = "<cout<<"\nAverage 1-10 = "<getch();
break;
case 4 :
int i43,j43;
//begin statement
clrscr();
cout<<"Display Multiply calculation :\n";
for(i43=2;i43<=4;i43++)//begin external loop
{
cout<<"Display Multiply calculation of "< for(j43=i43;j43<=12;j43++)//begin internal loop
{
cout< cout<<'n';
}//end of internal loop
cout<<"press any key to continue...";
getch();
}//end of external loop
cout<<"\nEnd of Program....\a\n";
getch();
break;
case 5 :
int i45;
clrscr();
i45=1;//set initial of veriable in shile conditio
while(i45<=5)
{
cout<<"I love C++Langauge\n";
i45++;//increase veriable value
}
getch();
break;
case 6 :
char ch44;
int count46;
//begin statement
clrscr();
count46 = 0;
cout<<"Please enter character : \n";
while (ch44!='8'&& ch44!='*'&&ch44!='a')
{
cin>>ch44; //enter character from keyboard
count46++; //count of timers that enter character
}
cout<<"Character"<cout<<"You enter"<getch();
break;
case 7 :
float number47,sum47,average47;
//begin statement
clrscr();
cout<<"Program calculate summation and average 1-10\n";
sum47=0; average47=0; number47=1;
while (number47<=10)//begin loop
{
cout<sum47+=number47;//same as...sum=sum+number
number47++;//increase variable+1
}//end loop
average47=sum47/(number47-1);
cout<<"\nSummation number 1-10 = "<cout<<"\nAverage number 1-10 = "<getch();
break;
case 8 :
int i48;
clrscr();
i48=1;//set initial of variable in do...while condiyion // begin loop
do
{
cout<<"I love C++ langauge \n";
i48++; //increase value of i variable+1
}while(i48<=5);//condition for loop
getch();
case 9 :
float number49,sum49,average49;
//begin statment
clrscr();
cout<<"Program claculate summation and average 1-10" ;
sum49=0;average49=0;number49=1;
do
{
cout<sum49+=number49;//calculate summation
number49++;
}while(number49<=10);
average49=sum49/(number49-1) ;
cout<<"\n Summation numbre 1-10=" <cout<<"\n Average number 1-10" << average49 ;
getch();
break;
case 10:
int x410,row410,sum410;
clrscr();
row410=0;sum410=0;
for(x410=1;x410<=100;++x410)//condition for 100 loop
{
cout<<"x = "<sum410+=x410;
row410++;
if(row410>23)//condition of break
break;
}
cout<<"summation 1-"<getch();
break;
case 11:
float x411,y411;
char choice411;
do
{
clrscr();
cout<<"\nProgram Divide Calculation x/y";
cout<<"\n**********************************";
cout<<"\nEnter X : ";
cin>>x411;
cout<<"\nEnter Y : ";
cin>>y411;
if(y411==0)
{
cout<<"\a\n\nCan't divide by aero !!!";
cout<<"\npress any key to continue...";
getch();
continue;//return to begin loop
}
cout<<"\n***Result "<?";
cin>>choice411;
}
while((choice411!='n')&&(choice411!='N'));
clrscr();
break;

}//end of do...while
}//end of switch
while(ch4!=0);
break;

case 5:
int ch5;
do
{
clrscr();
cout<<"\n Program By : pratya wutticho "<cout<<" No : 8 "<cout<<"************************************\n"<cout<<" Unit 5 "<cout<<" [1] Line_non "<cout<<" [2] Func_non "<cout<<" [3] Line_par "<cout<<" [4] Func_par "<cout<<" [5] Non_prot "<cout<<" [6] Inline "<cout<<" [7] Argument "<cout<<" [8] Over_fun "<cout<<" [9] Default "<cout<<" [10] Type_var "<cout<<" [11] Template "<cout<<" [0] Back To Manu \n "<cout<<"************************************"<cout<<"\nPlease Select [0-11] : ";
cin>>ch5;
switch(ch5)
{
case 1:
int i51;
clrscr();
cout<<"Display l line from iine() function\n";
cout<<"____________________________\n";
getch();
cout<<"Display 5 lines from line () function\n";
for (i51=1;i51<=5;++i51)
cout<<"____________________________\n";
getch();
break;

case 2:
int summation52();
int x52,y52;
clrscr();
int result52;
cout<<"Enter 2 number for summation:"<cout<<"Number1 :";cin>>x52;
cout<<"Number2 :";cin>>y52;
result52=x52+y52;
cout<<"Result of x+y=\a" <getch();
break;

case 3:
int amount53,i53=45;
clrscr();
cout<<"Display line from line () function \n";
amount53=30;
int x53,y53,z53;
for(x53=1;x53<=amount53;++x53)
cout<<"_";
cout<<'\n';
getch();
amount53=50;
for(y53=1;y53<=amount53;++y53)
cout<<"_";
cout<<'\n';
getch();
amount53=i53;
for(z53=1;z53<=amount53;++z53)
cout<<"_";
cout<<'\n';
getch();
break;

case 4:
float addition54;
float subtract54;
float multiply54;
float divide54;
float x54,y54;
clrscr();
cout<<"Enter 2 number for calculate:"<cout<<"Number1 :",cin>>x54;
cout<<"Number2 :",cin>>y54;
addition54=x54+y54;
subtract54=x54-y54;
multiply54=x54*y54;
divide54=x54/y54;
cout<<"Result of addition="<cout<<"Result of subtract="<cout<<"Result of multiply="<cout<<"Result of subtract="<getch();
cout<<"Calculate by sent argument to parameters of function .."<getch();
addition54=120.0+20.25;
subtract54=120.0-20.25;
multiply54=120.0*20.25;
divide54=120.0/20.25;
cout<<"Result of 10.0+20.25="<cout<<"Result of 10.0-20.25="<cout<<"Result of 10.0*20.25="<cout<<"Result of 10.0/20.25="<getch();
break;

case 5:
cout<<"_";
cout<<'\n';
clrscr();
cout<<"Display line from line1() function \n";
cout<<"________________________________________\n";
getch();
cout<<"\nDisplay line from line2() function\n";
cout<<"**********************\n" ;
cout<<"________________________________________";
getch();
break;

case 6:
int number56;
clrscr();
cout<<"Enter number to calculate square: ";
cin>>number56;
cout<<"Result of square ="<getch();
break;

case 7:
clrscr();
cout<<"Please enter 4 number for argument :\n";
cout<<"Argument1 :";cin>>arg1;
cout<<"Argument2 :";cin>>arg2;
cout<<"Argument3 :";cin>>arg3;
cout<<"Argument4 :";cin>>arg4;
cout<<"\n\n Display call function sum() and send value arument";
cout<<"\nValue argument before send to function:";
cout<<"\nArgument 1="<cout<<"\nArgument 1="<cout<<"\nValue argument before send to function:";
cout<<"\nArgument 3="<cout<<"\nArgument 3="<line58();
cout<<"Display 2 line from line()function\n";
line58(30);
cout<<"Display 3 line from line()function\n";
line58('*',60);
cout<<"Display 4 line from line()function\n";
line58('+');
getch();
break;

case 9:
clrscr();
cout<<"Display line from line() function\n";
line59();
line59('+');
line59('#',50);
line59(65);
getch();
break;

case 10:
clrscr();
line510();
repeat510();
for(y510=1;y510<=5;++y510)
line510();
for(x510=1;x510<=5;++x510)
repeat510();
getch();
break;

case 11:
int x511=50,y511=30;
float a511=300.25,b511=100.50;
double c511=3.21541005,d511=10005.02541152;
clrscr();
cout<<"Sum interger"<cout<<"Sum float"<cout<<"Sum double"<cout<<"\n Multiply interger"<cout<<" Multiply float"<cout<<" Multiply double"<< multiply511(c511,d511);
getch();
break;
}//end of do...while
}//end of switch
while(ch5!=0);
break;

case 6:
int ch6;
do
{
clrscr();
cout<<"\n Program By : pratya wutticho "<cout<<" No : 8 "<cout<<"************************************\n"<cout<<" Unit 6 "<cout<<" [1] Array1.CPP "<cout<<" [2] Arr_func.CPP "<cout<<" [3] Arr_2dim.CPP "<cout<<" [4] Arr_Fun1.CPP "<cout<<" [0] Back To Manu \n "<cout<<"************************************"<cout<<"\nPlease Select [0-10] : ";
cin>>ch6;
switch(ch6)
{
case 1 :int no60,score60[10];
float avg60=0,sum60=0;
clrscr();
cout<<"Please enter score of student 10 persons\n\n";
for(no60=0;no60<=9;++no60)
{cout<<"Std.#"<cin>>score60[no60];
}cout<<"O.K. you enter complete...press any key to display\n";
getch();clrscr();
cout<<"Display your enter score :\n";
for(no60=0;no60<=9;++no60)
{cout<<"Std.#"<cout<sum60+=score60[no60];
}
avg60=sum60/10.0;
cout<<"Summation of score ="<cout<<"Average of score ="<getch();
break;
case 2 :
int score62[10];
float avg62=0,sum62=0;

clrscr();
int no62;
cout<<"Please enter score of student 10 persons\n\n";
for(no62=0;no62<=9;++no62)
{cout<<"Std.#"<cin>>score62[no62];
}
cout<<"O.K. you enter complete...press any key to display\n";
getch();clrscr();
cout<<"Display your enter score :\n";
for(no62=0;no62<=9;++no62)
{cout<<"Std.#"<cout<sum62+=score62[no62];
avg62=sum62/10.0;
}
cout<<"Summation of score ="<cout<<"Average of score ="<getch();

break;
case 3:
int score63[10][3];
clrscr();
int std_no63,subj_no63,col63,row63;
cout<<"Please enter score of student 10 persons\n\n";
gotoxy(5,3);cout<<"Std# Math English Science";
col63=15;row63=5;
for(std_no63=0;std_no63<=9;++std_no63)
{gotoxy(7,row63);
cout<for(subj_no63=0;subj_no63<=2;++subj_no63)
{gotoxy(col63,row63);
cin>>score63[std_no63][subj_no63];
col63+=15;
}
row63++;
col63=15;
}
cout<<"O.K you enter complete...press any key to display\n\a";
getch();clrscr();
cout<<"*** Display score of student 10 persons 3 subject ***\n\n";
gotoxy(5,3);cout<<"Std# Math English Science";
col63=15;row63=5;
for(std_no63=0;std_no63<=9;++std_no63)
{gotoxy(7,row63);
cout<for(subj_no63=0;subj_no63<=2;++subj_no63)
{gotoxy(col63,row63);
cout<col63+=15;
}
row63++;col63=15;
}
cout<<"\n\nO.K. press any key to exit\n\a";
getch();
break;
case 4:
int number64[5]={10,20,30,40,50};
clrscr();
int i64,sum64=0,avg64;
for(i64=0;i64<=4;i64++)
cout<<"#"<for(i64=0;i64<=4;i64++)
sum64+=number64[i64];
avg64=sum64/5;
cout<<"\nSummation of All Array : "<cout<<"\nAverage of All Array : "<getch();
break;

}//end of do...while
}//end of switch
while(ch6!=0);
break;

}//End switch
}//End of do
while(ch !=0);
return 0;
}//End Program

float sum57(float para1,float para2)
{
return para1+para2;
}
float multiply57(float&para3, float&para4)
{
para3++;
para4++;
return para3*para4 ;
}

void line58()
{
cout<<"======================\n";
}
void line58(int x58)
{int y58;
for(y58=1;y58<=x58;++y58)
cout<<"_";
cout<<'\n';
}
void line58(char ch58,int x58)
{int y58;
for(y58=1;y58<=x58;++y58)
cout<cout<<'\n';
}
void line58(char ch58)
{int y58;
for(y58=1;y58<=80;++y58)
cout<cout<<'\n';
}

void line59(char ch59,int x59)
{
for(int y59=1;y59<=x59;++y59)
cout<cout<<'\n';
}

void line510()
{for(x510=1;x510<=80;x510++)
cout<<'=';
cout<}
void repeat510()
{int y510;
for(y510=1;y510<=40;++y510)
cout<<'#';
cout<}





ไม่มีความคิดเห็น:

แสดงความคิดเห็น