Home / การบ้านWeek6
Page options

การบ้านWeek6


ข้อที่ 1  

แสดงผล

 

ข้อ 2

main(){
   int a=0;
   do{
   clrscr();
   printf("-----Select Menu-----\n");
   printf("1.Sum\n2.Multiply\n3.Maximum\n4.Minimum\n5.Average\n6.Exit\n\n");
   printf("Select number 1-6 : ");
   scanf("%d",&a);
     switch(a){
       case 1:printf("Select Sum");getch();break;
       case 2:printf("Select Multiply");getch();break;
       case 3:printf("Select Maximum");getch();break;
       case 4:printf("Select Minimum");getch();break;
       case 5:printf("Select Average");getch();break;
       case 6:printf("Exit Selection");getch();break;
     }
   }
   while(a!=6);
   getch();
}

แสดงผล

ข้อ 3

main(){
   int x=0,a=-1,sum=0,max=0,min=0;
   double avg=0;
   clrscr();
   printf("Input integer number -99 Exit : ");
   scanf("%d",&x);
   max=x;
   min=x;
   while(x!=-99){
    sum=sum+x;
    a=a+1;
     if(x>max){
      max=x;
     }
     else if (x<min){
      min=x;
      }
    printf("Input integer number -99 Exit : ");
    scanf("%d",&x);
    }
    avg=sum/a;
    printf("Maximum=%d\n",max);
    printf("Minimum=%d\n",min);
    printf("Average=%f\n",avg);
   getch();
}

แสดงผล

ข้อ 4


แสดงผล

ข้อ ตัดเกรด 8 เกรด

main(){
   int score;
   clrscr();
   printf("Input score : ");
   scanf("%d",&score);
   if(score<=100&&score>=0){
      switch(score/5){
  case 20:printf("Your grade is A");getch();break;
  case 19:printf("Your grade is A");getch();break;
  case 18:printf("Your grade is A");getch();break;
  case 17:printf("Your grade is A");getch();break;
  case 16:printf("Your grade is B+");getch();break;
  case 15:printf("Your grade is B");getch();break;
  case 14:printf("Your grade is C+");getch();break;
  case 13:printf("Your grade is C");getch();break;
  case 12:printf("Your grade is D");getch();break;
  case 11:printf("Your grade is D+");getch();break;
  default:printf("Your grade is F");getch();break;
      }
   }
   else
   printf("You input wrong score");;
   getch();
}

แสดงผล


    Post a comment

    Your Name or E-mail ID (mandatory)

     

    Note: Your comment will be published after approval of the owner.

    No Attachments Found. Click here to upload new file.




     RSS of this page

    Author: boombalaka   Version: 1.6   Last Edited By: boombalaka   Modified: 10 Dec 2007