SlideShare une entreprise Scribd logo
1  sur  5
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

Contenu connexe

En vedette

คำสั่ง Switch
คำสั่ง Switchคำสั่ง Switch
คำสั่ง Switch
kramsri
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซี
kramsri
 
คำสั่ง For
คำสั่ง Forคำสั่ง For
คำสั่ง For
kramsri
 
Grand strategi agar koperasi1
Grand strategi agar koperasi1Grand strategi agar koperasi1
Grand strategi agar koperasi1
Irna Indriani
 
งานนำเสนอ1
งานนำเสนอ1งานนำเสนอ1
งานนำเสนอ1
kramsri
 
Linear day 17
Linear day 17Linear day 17
Linear day 17
cirilah
 
คำสั่ง Do while
คำสั่ง Do whileคำสั่ง Do while
คำสั่ง Do while
kramsri
 
คำสั่ง Switch.2
คำสั่ง Switch.2คำสั่ง Switch.2
คำสั่ง Switch.2
kramsri
 
คำสั่ง Do while
คำสั่ง Do whileคำสั่ง Do while
คำสั่ง Do while
kramsri
 
Aula3 sistemas lineares - parte1
Aula3   sistemas lineares - parte1Aula3   sistemas lineares - parte1
Aula3 sistemas lineares - parte1
rafamaco
 

En vedette (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
 

Similaire à คำสั่ง Switch

ภาษาซี
ภาษาซีภาษาซี
ภาษาซี
kramsri
 
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
 
C programs
C programsC programs
C programs
Minu S
 

Similaire à คำสั่ง 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
 

Plus de kramsri

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

Plus de 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