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

DOCX
คำสั่ง Switch
DOCX
Program to illustrate Switch, Goto and Exit statements.
PDF
Program to reflecta triangle
PDF
Switch
PDF
Algoritmos ensambladores
DOCX
Financialmodeling
PDF
Je ne sais pas maigrir dr dukan
PDF
Je ne sais pas maigrir dr dukan
คำสั่ง Switch
Program to illustrate Switch, Goto and Exit statements.
Program to reflecta triangle
Switch
Algoritmos ensambladores
Financialmodeling
Je ne sais pas maigrir dr dukan
Je ne sais pas maigrir dr dukan

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

PDF
Unit 1 ocs752 introduction to c programming
PDF
CP Handout#6
PDF
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
DOCX
C Language Programs
PDF
POP Unit 2.pptx.pdf for your time and gauss with example
PPTX
week4_lec2_switch-statement.pptx
PPTX
unit 2-Control Structures.pptx
DOC
C basics
PPTX
SIMPLE C PROGRAMS - SARASWATHI RAMALINGAM
PPT
Unit2 jwfiles
PPTX
CONTROL FLOW in C.pptx
PPT
C-Language Unit-2
PDF
Fundamentals of programming)
PPTX
Presentation1
PDF
Loop's definition and practical code in C programming
PPTX
C Language - Switch and For Loop
PPTX
Functions - Main Function - Function Prototyping - Inline Functions - Friend ...
DOC
'C' language notes (a.p)
PDF
6 c control statements branching &amp; jumping
DOCX
Practical File of C Language
Unit 1 ocs752 introduction to c programming
CP Handout#6
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
C Language Programs
POP Unit 2.pptx.pdf for your time and gauss with example
week4_lec2_switch-statement.pptx
unit 2-Control Structures.pptx
C basics
SIMPLE C PROGRAMS - SARASWATHI RAMALINGAM
Unit2 jwfiles
CONTROL FLOW in C.pptx
C-Language Unit-2
Fundamentals of programming)
Presentation1
Loop's definition and practical code in C programming
C Language - Switch and For Loop
Functions - Main Function - Function Prototyping - Inline Functions - Friend ...
'C' language notes (a.p)
6 c control statements branching &amp; jumping
Practical File of C Language
Ad

More from kramsri (14)

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

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