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

unit 4

#include
#include
#include
#include
void main()
{
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);

}





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

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