กF   If, If-Else



             ก   ก   กก
กF     If, If-Else
           ก         ก           F   F
       F           Fก        F
Fก F       F   ก         ก
ก   F กF   if   F
1 F if     F
    if (expression)
         {
              statement 1;
              statement 2;
         }


      F

int x=5;
if (x<10)
{
   printf("x is less than 10n");
}
2 F if–else
if (expression)
     {
          statement   1;
          statement   2;
     }
else
     {
          statement   3;
          statement   4;
     }
2 F if–else
       F
int your_number;
printf("Enter a whole number: ");
scanf("%d",&your_number);

if (your_number % 2 == 0)
{
    printf("Your number is evenn");
}
else
{
    printf("Your number is oddn");
}

บทที่ 6 2 ฟังก์ชัน if if-else [slide]

  • 1.
    กF If, If-Else ก ก กก
  • 2.
    กF If, If-Else ก ก F F F Fก F Fก F F ก ก
  • 3.
    F กF if F
  • 4.
    1 F if F if (expression) { statement 1; statement 2; } F int x=5; if (x<10) { printf("x is less than 10n"); }
  • 5.
    2 F if–else if(expression) { statement 1; statement 2; } else { statement 3; statement 4; }
  • 6.
    2 F if–else F int your_number; printf("Enter a whole number: "); scanf("%d",&your_number); if (your_number % 2 == 0) { printf("Your number is evenn"); } else { printf("Your number is oddn"); }