Page 944 - เตรียมสอบครูผู้ช่วยคอมพิวเตอร์_compressed
P. 944

ี
                                                                ี
                                                                            ่
                                           แบบทดสอบก่อนเรยนหน่วยท 6

                                                                    ่
                                                  ้
                                          โครงสรางควบคุมแบบเงือนไขกรณ          ี
               ค้าชีๅ฽จง༛฿หຌ฼ลือกค้าตอบทีไถูกตຌองทีไสุด฼พียงค้าตอบ฼ดียว༛

               1. ขຌอ฿ด฼ปຓนลักษณะของ฾ปร฽กรม฽บบ฾ครงสรຌางทาง฼ลือก฼ดียว หรือ฽บบล้าดับ
               ༛ก.      scanf(“%d”, &number);

                         if (number < 20 || number > 60)
                            printf(“Number %d is out of range”, number);

               ༛ข.      scanf(“%d”, &y);

                   (       10 > y) ? printf(“Y less than 10”) : printf(“X not more than Y”);
                     ค. printf(“Input birth of years ==>”);

                         scanf(“%d”,&birth_year);

                         age = current_year – birth_year;
                         printf(“I am  %d years old\n”,age);

               ༛ง.      scanf(“%d”, &number);

                         if (number >10) {
                                printf(“Number %d is over than 10”, number);

                                number = number – 5;
                         } else

                                printf(“Number %d is not over than10”, number);

               2. ขຌอ฿ด฼ปຓนลักษณะของ฾ปร฽กรม฽บบ฾ครงสรຌางทาง฼ลือกดຌวยค้าสัไง༛if
                     ก. scanf(“%d”, &number);༛ข.               scanf(“%d”, &y);

                       if (number < 20 || number > 60) (           10 > y) ? printf(“Y less than 10”) :
                       printf(“Number %d is out of range”,        printf(“X not more than Y”);

                        number);

               ༛ค.      printf(“Input birth of years ==>”); ༛ง.   scanf(“%d”, &number);
                       scanf(“%d”,&birth_year);                 while (number > 10) {

                       age = current_year – birth_year;           printf(“Number %d is over than 10”

                       printf(“I am  %d years old\n”,age);         , number);
               3. ขຌอ฿ด฼ปຓนผลรันของ฾ปร฽กรมต຋อเปนีๅ༛

               #include<stdio.h>
               void main(){



                                                                                                         1
   939   940   941   942   943   944   945   946   947   948   949