SlideShare a Scribd company logo
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();
}
Flowchart




                     Kittawan
           Tamprasert No.
                M.




                      Choice




    yes
               Choice=3


                        no




Choice=1                        Choice=2



Num1+num2                       Num1-num2

More Related Content

Viewers also liked

คำสั่ง Switch
คำสั่ง Switchคำสั่ง Switch
คำสั่ง Switchkramsri
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซีkramsri
 
คำสั่ง For
คำสั่ง Forคำสั่ง For
คำสั่ง Forkramsri
 
The Design Innovation Cooperative
The Design Innovation CooperativeThe Design Innovation Cooperative
The Design Innovation Cooperative
Nathaniel Eck
 
Grand strategi agar koperasi1
Grand strategi agar koperasi1Grand strategi agar koperasi1
Grand strategi agar koperasi1Irna Indriani
 
งานนำเสนอ1
งานนำเสนอ1งานนำเสนอ1
งานนำเสนอ1kramsri
 
Sample template to report internet dns's performance
Sample template to report internet dns's performanceSample template to report internet dns's performance
Sample template to report internet dns's performance
Mustafa Golam
 
accreditation 2
 accreditation 2 accreditation 2
accreditation 2
Tota Essam
 
Linear day 17
Linear day 17Linear day 17
Linear day 17cirilah
 
คำสั่ง Do while
คำสั่ง Do whileคำสั่ง Do while
คำสั่ง Do whilekramsri
 
คำสั่ง Switch.2
คำสั่ง Switch.2คำสั่ง Switch.2
คำสั่ง Switch.2kramsri
 
คำสั่ง Do while
คำสั่ง Do whileคำสั่ง Do while
คำสั่ง Do whilekramsri
 
Aula3 sistemas lineares - parte1
Aula3   sistemas lineares - parte1Aula3   sistemas lineares - parte1
Aula3 sistemas lineares - parte1rafamaco
 
Treliça inclinada-pronto11
 Treliça inclinada-pronto11 Treliça inclinada-pronto11
Treliça inclinada-pronto11
Fer Nando
 

Viewers also liked (16)

คำสั่ง Switch
คำสั่ง Switchคำสั่ง Switch
คำสั่ง Switch
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซี
 
คำสั่ง For
คำสั่ง Forคำสั่ง For
คำสั่ง For
 
The Design Innovation Cooperative
The Design Innovation CooperativeThe Design Innovation Cooperative
The Design Innovation Cooperative
 
Grand strategi agar koperasi1
Grand strategi agar koperasi1Grand strategi agar koperasi1
Grand strategi agar koperasi1
 
Ekonomi koperasi
Ekonomi koperasiEkonomi koperasi
Ekonomi koperasi
 
Curiosites 11
Curiosites 11Curiosites 11
Curiosites 11
 
งานนำเสนอ1
งานนำเสนอ1งานนำเสนอ1
งานนำเสนอ1
 
Sample template to report internet dns's performance
Sample template to report internet dns's performanceSample template to report internet dns's performance
Sample template to report internet dns's performance
 
accreditation 2
 accreditation 2 accreditation 2
accreditation 2
 
Linear day 17
Linear day 17Linear day 17
Linear day 17
 
คำสั่ง Do while
คำสั่ง Do whileคำสั่ง Do while
คำสั่ง Do while
 
คำสั่ง Switch.2
คำสั่ง Switch.2คำสั่ง Switch.2
คำสั่ง Switch.2
 
คำสั่ง Do while
คำสั่ง Do whileคำสั่ง Do while
คำสั่ง Do while
 
Aula3 sistemas lineares - parte1
Aula3   sistemas lineares - parte1Aula3   sistemas lineares - parte1
Aula3 sistemas lineares - parte1
 
Treliça inclinada-pronto11
 Treliça inclinada-pronto11 Treliça inclinada-pronto11
Treliça inclinada-pronto11
 

Similar to คำสั่ง Switch

C Programming Example
C Programming Example C Programming Example
C Programming Example
University of Potsdam
 
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชันตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
Warawut
 
Numerical Methods in C
Numerical Methods in CNumerical Methods in C
Numerical Methods in C
Ambili Baby
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซีkramsri
 
C programs
C programsC programs
C programs
Vikram Nandini
 
CP Handout#6
CP Handout#6CP Handout#6
CP Handout#6
trupti1976
 
Program to reflecta triangle
Program to reflecta triangleProgram to reflecta triangle
Program to reflecta triangle
Tanya Makkar
 
SIMPLE C PROGRAMS - SARASWATHI RAMALINGAM
SIMPLE C PROGRAMS - SARASWATHI RAMALINGAMSIMPLE C PROGRAMS - SARASWATHI RAMALINGAM
SIMPLE C PROGRAMS - SARASWATHI RAMALINGAM
SaraswathiRamalingam
 
1. Translation program#includestdio.h#includeconio.h#incl.pdf
1. Translation program#includestdio.h#includeconio.h#incl.pdf1. Translation program#includestdio.h#includeconio.h#incl.pdf
1. Translation program#includestdio.h#includeconio.h#incl.pdf
sutharbharat59
 
Incorporate the SOR method in the multigridTest-m and apply the multig.pdf
Incorporate the SOR method in the multigridTest-m and apply the multig.pdfIncorporate the SOR method in the multigridTest-m and apply the multig.pdf
Incorporate the SOR method in the multigridTest-m and apply the multig.pdf
aartechindia
 
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 .
 
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
BUBT
 
C programs
C programsC programs
C programsMinu S
 
cpract.docx
cpract.docxcpract.docx
cpract.docx
PRATIKSHABHOYAR6
 
array
arrayarray
array
teach4uin
 
The solution manual of programming in ansi by Robin
The solution manual of programming in ansi by RobinThe solution manual of programming in ansi by Robin
The solution manual of programming in ansi by Robin
Shariful Haque Robin
 
C Programming lab
C Programming labC Programming lab
C Programming lab
Vikram Nandini
 

Similar to คำสั่ง Switch (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
 
CP Handout#6
CP Handout#6CP Handout#6
CP Handout#6
 
Progr3
Progr3Progr3
Progr3
 
Program to reflecta triangle
Program to reflecta triangleProgram to reflecta triangle
Program to reflecta triangle
 
SIMPLE C PROGRAMS - SARASWATHI RAMALINGAM
SIMPLE C PROGRAMS - SARASWATHI RAMALINGAMSIMPLE C PROGRAMS - SARASWATHI RAMALINGAM
SIMPLE C PROGRAMS - SARASWATHI RAMALINGAM
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
 
1. Translation program#includestdio.h#includeconio.h#incl.pdf
1. Translation program#includestdio.h#includeconio.h#incl.pdf1. Translation program#includestdio.h#includeconio.h#incl.pdf
1. Translation program#includestdio.h#includeconio.h#incl.pdf
 
Incorporate the SOR method in the multigridTest-m and apply the multig.pdf
Incorporate the SOR method in the multigridTest-m and apply the multig.pdfIncorporate the SOR method in the multigridTest-m and apply the multig.pdf
Incorporate the SOR method in the multigridTest-m and apply the multig.pdf
 
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 ...
 
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
 
SaraPIC
SaraPICSaraPIC
SaraPIC
 
C programs
C programsC programs
C programs
 
cpract.docx
cpract.docxcpract.docx
cpract.docx
 
array
arrayarray
array
 
The solution manual of programming in ansi by Robin
The solution manual of programming in ansi by RobinThe solution manual of programming in ansi by Robin
The solution manual of programming in ansi by Robin
 
C Programming lab
C Programming labC Programming lab
C Programming lab
 

More from kramsri

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

More from kramsri (6)

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

คำสั่ง Switch

  • 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. }
  • 4.
  • 5. Flowchart Kittawan Tamprasert No. M. Choice yes Choice=3 no Choice=1 Choice=2 Num1+num2 Num1-num2