SlideShare a Scribd company logo
1 of 5
Download to read offline
Switch

#include<stdio.h>

#include<conio.h>

#include<stdlib.h>

main ()

{

    printf("Nisarat Kramsri     No.16        M.6/1nn");

Nisarat Kramsri         No.16        M.6/1

       int choice;

       float num1,num2;                  num1,num2

       printf("Please select choicen");

       printf("1.Program additionn");

       printf("2.Program substractionn");

       printf("3.Exit programn");

       scanf("%d",&choice);
switch(choice)                switch

   case 3:exit(3);

   printf("Enter number1: ");

   scanf("%f",&num1);

   printf("Enter number2: ");

   scanf("%f",&num2);

   switch(choice)               switch

   {

   case 1:

printf("%.2f+%.2f=%.2fn",num1,num2,num1+num2);break;




   case 2: printf("%.2f-%.2f=%.2fn",num1,num2,num1-
num2);break;



   }

   getch();
}
คำสั่ง Switch.2
Flowchart




              nisarat kramsri
            No.16 M.




                   Choice




    yes
              Choice=3


                       no




Choice=1                        Choice=2



Num1+num2                       Num1-num2

More Related Content

Similar to คำสั่ง Switch.2

ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชันตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชันWarawut
 
Numerical Methods in C
Numerical Methods in CNumerical Methods in C
Numerical Methods in CAmbili Baby
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซีkramsri
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซีkramsri
 
SIMPLE C PROGRAMS - SARASWATHI RAMALINGAM
SIMPLE C PROGRAMS - SARASWATHI RAMALINGAMSIMPLE C PROGRAMS - SARASWATHI RAMALINGAM
SIMPLE C PROGRAMS - SARASWATHI RAMALINGAMSaraswathiRamalingam
 
Chapter 5 Balagurusamy Programming ANSI in c
Chapter 5 Balagurusamy Programming ANSI  in cChapter 5 Balagurusamy Programming ANSI  in c
Chapter 5 Balagurusamy Programming ANSI in cBUBT
 
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...DR B.Surendiran .
 
C programs
C programsC programs
C programsMinu S
 
Practical File of C Language
Practical File of C LanguagePractical File of C Language
Practical File of C LanguageRAJWANT KAUR
 
function xx = key2note(X, keynum, dur) KEY2NOTE Produce a sinuso.pdf
function xx = key2note(X, keynum, dur)  KEY2NOTE Produce a sinuso.pdffunction xx = key2note(X, keynum, dur)  KEY2NOTE Produce a sinuso.pdf
function xx = key2note(X, keynum, dur) KEY2NOTE Produce a sinuso.pdfannethafashion
 
Write 2 function files in matlab one for fixed-point iteration for.pdf
Write 2 function files in matlab  one for fixed-point iteration for.pdfWrite 2 function files in matlab  one for fixed-point iteration for.pdf
Write 2 function files in matlab one for fixed-point iteration for.pdfneetuarya13
 

Similar to คำสั่ง Switch.2 (20)

ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชันตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
 
Numerical Methods in C
Numerical Methods in CNumerical Methods in C
Numerical Methods in C
 
C programs
C programsC programs
C programs
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซี
 
บทที่ 3
บทที่ 3บทที่ 3
บทที่ 3
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซี
 
CP Handout#6
CP Handout#6CP Handout#6
CP Handout#6
 
Progr3
Progr3Progr3
Progr3
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
 
SIMPLE C PROGRAMS - SARASWATHI RAMALINGAM
SIMPLE C PROGRAMS - SARASWATHI RAMALINGAMSIMPLE C PROGRAMS - SARASWATHI RAMALINGAM
SIMPLE C PROGRAMS - SARASWATHI RAMALINGAM
 
Chapter 5 Balagurusamy Programming ANSI in c
Chapter 5 Balagurusamy Programming ANSI  in cChapter 5 Balagurusamy Programming ANSI  in c
Chapter 5 Balagurusamy Programming ANSI in c
 
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
 
SaraPIC
SaraPICSaraPIC
SaraPIC
 
C programs
C programsC programs
C programs
 
cpract.docx
cpract.docxcpract.docx
cpract.docx
 
Practical File of C Language
Practical File of C LanguagePractical File of C Language
Practical File of C Language
 
function xx = key2note(X, keynum, dur) KEY2NOTE Produce a sinuso.pdf
function xx = key2note(X, keynum, dur)  KEY2NOTE Produce a sinuso.pdffunction xx = key2note(X, keynum, dur)  KEY2NOTE Produce a sinuso.pdf
function xx = key2note(X, keynum, dur) KEY2NOTE Produce a sinuso.pdf
 
7 functions
7  functions7  functions
7 functions
 
Write 2 function files in matlab one for fixed-point iteration for.pdf
Write 2 function files in matlab  one for fixed-point iteration for.pdfWrite 2 function files in matlab  one for fixed-point iteration for.pdf
Write 2 function files in matlab one for fixed-point iteration for.pdf
 

More from kramsri

ข อสอบคอม 5 ข อส่ง
ข อสอบคอม 5 ข อส่งข อสอบคอม 5 ข อส่ง
ข อสอบคอม 5 ข อส่งkramsri
 
ข อสอบคอม #6
ข อสอบคอม #6ข อสอบคอม #6
ข อสอบคอม #6kramsri
 
งานนำเสนอ1
งานนำเสนอ1งานนำเสนอ1
งานนำเสนอ1kramsri
 
คำสั่ง Switch
คำสั่ง Switchคำสั่ง Switch
คำสั่ง Switchkramsri
 
คำสั่ง Switch
คำสั่ง Switchคำสั่ง Switch
คำสั่ง Switchkramsri
 
คำสั่ง For
คำสั่ง Forคำสั่ง For
คำสั่ง Forkramsri
 
คำสั่ง Do while
คำสั่ง Do whileคำสั่ง Do while
คำสั่ง Do whilekramsri
 
คำสั่ง Do while
คำสั่ง Do whileคำสั่ง Do while
คำสั่ง Do whilekramsri
 
ประเม นรายงาน กล _มท__ 2 คำส__งควบค_มข__นพ__นฐานภาษาซ_ (1)
ประเม นรายงาน กล _มท__ 2 คำส__งควบค_มข__นพ__นฐานภาษาซ_ (1)ประเม นรายงาน กล _มท__ 2 คำส__งควบค_มข__นพ__นฐานภาษาซ_ (1)
ประเม นรายงาน กล _มท__ 2 คำส__งควบค_มข__นพ__นฐานภาษาซ_ (1)kramsri
 
ประเม นรายงาน กล _มท__ 2 คำส__งควบค_มข__นพ__นฐานภาษาซ_
ประเม นรายงาน กล _มท__ 2 คำส__งควบค_มข__นพ__นฐานภาษาซ_ประเม นรายงาน กล _มท__ 2 คำส__งควบค_มข__นพ__นฐานภาษาซ_
ประเม นรายงาน กล _มท__ 2 คำส__งควบค_มข__นพ__นฐานภาษาซ_kramsri
 
ความคิดเห็นเพื่อน(แบบประเมิน)
ความคิดเห็นเพื่อน(แบบประเมิน)ความคิดเห็นเพื่อน(แบบประเมิน)
ความคิดเห็นเพื่อน(แบบประเมิน)kramsri
 
ประกวดภาพถ่าย
ประกวดภาพถ่ายประกวดภาพถ่าย
ประกวดภาพถ่ายkramsri
 

More from kramsri (12)

ข อสอบคอม 5 ข อส่ง
ข อสอบคอม 5 ข อส่งข อสอบคอม 5 ข อส่ง
ข อสอบคอม 5 ข อส่ง
 
ข อสอบคอม #6
ข อสอบคอม #6ข อสอบคอม #6
ข อสอบคอม #6
 
งานนำเสนอ1
งานนำเสนอ1งานนำเสนอ1
งานนำเสนอ1
 
คำสั่ง Switch
คำสั่ง Switchคำสั่ง Switch
คำสั่ง Switch
 
คำสั่ง Switch
คำสั่ง Switchคำสั่ง Switch
คำสั่ง Switch
 
คำสั่ง For
คำสั่ง Forคำสั่ง For
คำสั่ง For
 
คำสั่ง Do while
คำสั่ง Do whileคำสั่ง Do while
คำสั่ง Do while
 
คำสั่ง Do while
คำสั่ง Do whileคำสั่ง Do while
คำสั่ง Do while
 
ประเม นรายงาน กล _มท__ 2 คำส__งควบค_มข__นพ__นฐานภาษาซ_ (1)
ประเม นรายงาน กล _มท__ 2 คำส__งควบค_มข__นพ__นฐานภาษาซ_ (1)ประเม นรายงาน กล _มท__ 2 คำส__งควบค_มข__นพ__นฐานภาษาซ_ (1)
ประเม นรายงาน กล _มท__ 2 คำส__งควบค_มข__นพ__นฐานภาษาซ_ (1)
 
ประเม นรายงาน กล _มท__ 2 คำส__งควบค_มข__นพ__นฐานภาษาซ_
ประเม นรายงาน กล _มท__ 2 คำส__งควบค_มข__นพ__นฐานภาษาซ_ประเม นรายงาน กล _มท__ 2 คำส__งควบค_มข__นพ__นฐานภาษาซ_
ประเม นรายงาน กล _มท__ 2 คำส__งควบค_มข__นพ__นฐานภาษาซ_
 
ความคิดเห็นเพื่อน(แบบประเมิน)
ความคิดเห็นเพื่อน(แบบประเมิน)ความคิดเห็นเพื่อน(แบบประเมิน)
ความคิดเห็นเพื่อน(แบบประเมิน)
 
ประกวดภาพถ่าย
ประกวดภาพถ่ายประกวดภาพถ่าย
ประกวดภาพถ่าย
 

คำสั่ง Switch.2

  • 1. Switch #include<stdio.h> #include<conio.h> #include<stdlib.h> main () { printf("Nisarat Kramsri No.16 M.6/1nn"); Nisarat Kramsri No.16 M.6/1 int choice; float num1,num2; num1,num2 printf("Please select choicen"); printf("1.Program additionn"); printf("2.Program substractionn"); printf("3.Exit programn"); scanf("%d",&choice);
  • 2. switch(choice) switch case 3:exit(3); printf("Enter number1: "); scanf("%f",&num1); printf("Enter number2: "); scanf("%f",&num2); switch(choice) switch { case 1: printf("%.2f+%.2f=%.2fn",num1,num2,num1+num2);break; case 2: printf("%.2f-%.2f=%.2fn",num1,num2,num1- num2);break; } getch();
  • 3. }
  • 5. Flowchart nisarat kramsri No.16 M. Choice yes Choice=3 no Choice=1 Choice=2 Num1+num2 Num1-num2