SlideShare a Scribd company logo
1:   #include <stdio.h>
 2:   #include <stdlib.h>
 3:   #include <conio.h>
 4:
 5:   void add() {
 6:       int num1, num2, result;
 7:
 8:       printf("nn");
 9:       printf("Input number 1: ");
10:       scanf("%d", &num1);
11:       printf("Input number 2: ");
12:       scanf("%d", &num2);
13:
14:       result = num1 + num2;
15:
16:       printf("t%d + %d = %dn", num1, num2, result);
17:   }
18:
19:   void subtrack() {
20:       int num1, num2, result;
21:
22:       printf("nn");
23:       printf("Input number 1: ");
24:       scanf("%d", &num1);
25:       printf("Input number 2: ");
26:       scanf("%d", &num2);
27:
28:       result = num1 - num2;
29:
30:       printf("t%d - %d = %dn", num1, num2, result);
31:   }
32:
33:   void multiple() {
34:       int num1, num2, result;
35:
36:       printf("nn");
37:       printf("Input number 1: ");
38:       scanf("%d", &num1);
39:       printf("Input number 2: ");
40:       scanf("%d", &num2);
41:
42:       result = num1 * num2;
43:
44:       printf("t%d * %d = %dn", num1, num2, result);
45:   }
46:
47:   void divide() {
48:       float num1, num2, result;
49:
50:       printf("nn");
51:       printf("Input number 1: ");
52:       scanf("%f", &num1);
53:       printf("Input number 2: ");
54:       scanf("%f", &num2);
55:
56:       result = num1 / num2;
57:
58:       printf("t%.2f / %.2f = %.2fn", num1, num2, result);
59:   }
60:
61:   void menu() {
62:       char c;
63:
64:       do {
65:           printf("n--- MAIN MENU ---n");
66:           printf("A) Additionaln");
67:           printf("S) Subtrackn");
68:           printf("M) Multiplen");
69:           printf("D) Dividen");
70:           printf("Q) Quitn");
71:           printf("   Select choice: ");
72:           c = getch();
73:
74:          switch (c) {
75:              case 'a':
76:                   add();
77:                   break;
78:              case 's':
79:                    subtrack();
80:                    break;
81:              case 'm':
82:                   multiple();
83:                   break;
84:              case 'd':
85:                   divide();
86:                   break;
87:              case 'q':
88:                   printf("nnGood bye!!!n");
89:           }
90:       } while ((c != 'q'));
91: }
92:
93: int   main() {
94:       menu();
95:       system("PAUSE");
96:       return 0;
97: }
98:

More Related Content

What's hot

Najmul
Najmul  Najmul
Najmul
Najmul Ashik
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word document
Syed Umair
 
Calculator in cpp
Calculator in cppCalculator in cpp
Calculator in cpp
SitaramAgarwal
 
C언어 스터디 강의자료 - 1차시
C언어 스터디 강의자료 - 1차시C언어 스터디 강의자료 - 1차시
C언어 스터디 강의자료 - 1차시
Junha Jang
 
One dimensional operation of Array in C- language
One dimensional operation of Array in C- language One dimensional operation of Array in C- language
One dimensional operation of Array in C- language
9096308941
 
1 (1)
1 (1)1 (1)
1 (1)
Krish Na
 
Add digits of number in c
Add digits of number in c Add digits of number in c
Add digits of number in c
mohdshanu
 
Implementation of strassens
Implementation of  strassensImplementation of  strassens
Implementation of strassensVikash Dhal
 
เขียนโปรแกรมภาษา C: คำสั่ง switch
เขียนโปรแกรมภาษา C: คำสั่ง switchเขียนโปรแกรมภาษา C: คำสั่ง switch
เขียนโปรแกรมภาษา C: คำสั่ง switch
Warawut
 
Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1
Dr. Loganathan R
 
Maple Code for Steepest Descent
Maple Code for Steepest DescentMaple Code for Steepest Descent
Maple Code for Steepest DescentJeremy Lane
 
Palindrome number program c
Palindrome number program cPalindrome number program c
Palindrome number program c
mohdshanu
 

What's hot (14)

Najmul
Najmul  Najmul
Najmul
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word document
 
Calculator in cpp
Calculator in cppCalculator in cpp
Calculator in cpp
 
C언어 스터디 강의자료 - 1차시
C언어 스터디 강의자료 - 1차시C언어 스터디 강의자료 - 1차시
C언어 스터디 강의자료 - 1차시
 
บทที่ 3
บทที่ 3บทที่ 3
บทที่ 3
 
One dimensional operation of Array in C- language
One dimensional operation of Array in C- language One dimensional operation of Array in C- language
One dimensional operation of Array in C- language
 
1 (1)
1 (1)1 (1)
1 (1)
 
Add digits of number in c
Add digits of number in c Add digits of number in c
Add digits of number in c
 
Implementation of strassens
Implementation of  strassensImplementation of  strassens
Implementation of strassens
 
เขียนโปรแกรมภาษา C: คำสั่ง switch
เขียนโปรแกรมภาษา C: คำสั่ง switchเขียนโปรแกรมภาษา C: คำสั่ง switch
เขียนโปรแกรมภาษา C: คำสั่ง switch
 
Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1
 
Maple Code for Steepest Descent
Maple Code for Steepest DescentMaple Code for Steepest Descent
Maple Code for Steepest Descent
 
Palindrome number program c
Palindrome number program cPalindrome number program c
Palindrome number program c
 
Test2
Test2Test2
Test2
 

Viewers also liked

Connect MySQL
Connect MySQLConnect MySQL
Connect MySQL
Warawut
 
Database Design
Database DesignDatabase Design
Database Design
Warawut
 
Chapter 2 Strategy & Information System
Chapter 2 Strategy & Information SystemChapter 2 Strategy & Information System
Chapter 2 Strategy & Information System
Warawut
 
เอกสารประกอบการบรรยาย
เอกสารประกอบการบรรยายเอกสารประกอบการบรรยาย
เอกสารประกอบการบรรยาย
Warawut
 
Additional Information
Additional InformationAdditional Information
Additional Information
Warawut
 
Structure Statement VB.NET 2005
Structure Statement VB.NET 2005Structure Statement VB.NET 2005
Structure Statement VB.NET 2005
Warawut
 
04 connect-db-tools
 04 connect-db-tools 04 connect-db-tools
04 connect-db-tools
Warawut
 
Search Data
Search DataSearch Data
Search Data
Warawut
 
การควบคุมภาษา C
การควบคุมภาษา Cการควบคุมภาษา C
การควบคุมภาษา C
Warawut
 

Viewers also liked (9)

Connect MySQL
Connect MySQLConnect MySQL
Connect MySQL
 
Database Design
Database DesignDatabase Design
Database Design
 
Chapter 2 Strategy & Information System
Chapter 2 Strategy & Information SystemChapter 2 Strategy & Information System
Chapter 2 Strategy & Information System
 
เอกสารประกอบการบรรยาย
เอกสารประกอบการบรรยายเอกสารประกอบการบรรยาย
เอกสารประกอบการบรรยาย
 
Additional Information
Additional InformationAdditional Information
Additional Information
 
Structure Statement VB.NET 2005
Structure Statement VB.NET 2005Structure Statement VB.NET 2005
Structure Statement VB.NET 2005
 
04 connect-db-tools
 04 connect-db-tools 04 connect-db-tools
04 connect-db-tools
 
Search Data
Search DataSearch Data
Search Data
 
การควบคุมภาษา C
การควบคุมภาษา Cการควบคุมภาษา C
การควบคุมภาษา C
 

Similar to ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน

C programs
C programsC programs
C programs
Vikram Nandini
 
C lab programs
C lab programsC lab programs
C lab programs
Dr. Prashant Vats
 
C lab programs
C lab programsC lab programs
C lab programs
Dr. Prashant Vats
 
C-programs
C-programsC-programs
C-programs
SSGMCE SHEGAON
 
cpract.docx
cpract.docxcpract.docx
cpract.docx
PRATIKSHABHOYAR6
 
C programs Set 2
C programs Set 2C programs Set 2
C programs Set 2
Koshy Geoji
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
University of Potsdam
 
C Programming lab
C Programming labC Programming lab
C Programming lab
Vikram Nandini
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
Wingston
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
PRATHAMESH DESHPANDE
 
C basics
C basicsC basics
C basicsMSc CST
 
All important c programby makhan kumbhkar
All important c programby makhan kumbhkarAll important c programby makhan kumbhkar
All important c programby makhan kumbhkar
sandeep kumbhkar
 
คำสั่ง Switch
คำสั่ง Switchคำสั่ง Switch
คำสั่ง Switchkramsri
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
Azhar Javed
 
C programms
C programmsC programms
C programms
Mukund Gandrakota
 
Program flowchart
Program flowchartProgram flowchart
Program flowchart
Sowri Rajan
 
C Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossainC Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossain
Sazzad Hossain, ITP, MBA, CSCA™
 
C file
C fileC file

Similar to ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน (20)

C programs
C programsC programs
C programs
 
C lab programs
C lab programsC lab programs
C lab programs
 
C lab programs
C lab programsC lab programs
C lab programs
 
C-programs
C-programsC-programs
C-programs
 
cpract.docx
cpract.docxcpract.docx
cpract.docx
 
C programs Set 2
C programs Set 2C programs Set 2
C programs Set 2
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
 
C Programming lab
C Programming labC Programming lab
C Programming lab
 
Progr3
Progr3Progr3
Progr3
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
C basics
C basicsC basics
C basics
 
All important c programby makhan kumbhkar
All important c programby makhan kumbhkarAll important c programby makhan kumbhkar
All important c programby makhan kumbhkar
 
คำสั่ง Switch
คำสั่ง Switchคำสั่ง Switch
คำสั่ง Switch
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
C programms
C programmsC programms
C programms
 
Program flowchart
Program flowchartProgram flowchart
Program flowchart
 
C Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossainC Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossain
 
C file
C fileC file
C file
 

More from Warawut

Database design
Database designDatabase design
Database design
Warawut
 
Business Computer Project 4
Business Computer Project 4Business Computer Project 4
Business Computer Project 4
Warawut
 
Object-Oriented Programming 10
Object-Oriented Programming 10Object-Oriented Programming 10
Object-Oriented Programming 10
Warawut
 
Object-Oriented Programming 9
Object-Oriented Programming 9Object-Oriented Programming 9
Object-Oriented Programming 9
Warawut
 
Object-Oriented Programming 8
Object-Oriented Programming 8Object-Oriented Programming 8
Object-Oriented Programming 8
Warawut
 
Object-Oriented Programming 7
Object-Oriented Programming 7Object-Oriented Programming 7
Object-Oriented Programming 7
Warawut
 
Object-Oriented Programming 6
Object-Oriented Programming 6Object-Oriented Programming 6
Object-Oriented Programming 6
Warawut
 
Management Information System 6
Management Information System 6Management Information System 6
Management Information System 6
Warawut
 
Management Information System 5
Management Information System 5Management Information System 5
Management Information System 5
Warawut
 
Management Information System 4
Management Information System 4Management Information System 4
Management Information System 4
Warawut
 
Object-Oriented Programming 5
Object-Oriented Programming 5Object-Oriented Programming 5
Object-Oriented Programming 5
Warawut
 
Business Computer Project 3
Business Computer Project 3Business Computer Project 3
Business Computer Project 3
Warawut
 
Management Information System 3
Management Information System 3Management Information System 3
Management Information System 3
Warawut
 
Business Computer Project 2
Business Computer Project 2Business Computer Project 2
Business Computer Project 2
Warawut
 
Object-Oriented Programming 4
Object-Oriented Programming 4Object-Oriented Programming 4
Object-Oriented Programming 4
Warawut
 
Business Computer Project 1
Business Computer Project 1Business Computer Project 1
Business Computer Project 1
Warawut
 
Chapter 1 Organization & MIS
Chapter 1 Organization & MISChapter 1 Organization & MIS
Chapter 1 Organization & MIS
Warawut
 
Object-Oriented Programming 3
Object-Oriented Programming 3Object-Oriented Programming 3
Object-Oriented Programming 3
Warawut
 
Object-Oriented Programming 2
Object-Oriented Programming 2Object-Oriented Programming 2
Object-Oriented Programming 2
Warawut
 
Object-Oriented Programming 1
Object-Oriented Programming 1Object-Oriented Programming 1
Object-Oriented Programming 1
Warawut
 

More from Warawut (20)

Database design
Database designDatabase design
Database design
 
Business Computer Project 4
Business Computer Project 4Business Computer Project 4
Business Computer Project 4
 
Object-Oriented Programming 10
Object-Oriented Programming 10Object-Oriented Programming 10
Object-Oriented Programming 10
 
Object-Oriented Programming 9
Object-Oriented Programming 9Object-Oriented Programming 9
Object-Oriented Programming 9
 
Object-Oriented Programming 8
Object-Oriented Programming 8Object-Oriented Programming 8
Object-Oriented Programming 8
 
Object-Oriented Programming 7
Object-Oriented Programming 7Object-Oriented Programming 7
Object-Oriented Programming 7
 
Object-Oriented Programming 6
Object-Oriented Programming 6Object-Oriented Programming 6
Object-Oriented Programming 6
 
Management Information System 6
Management Information System 6Management Information System 6
Management Information System 6
 
Management Information System 5
Management Information System 5Management Information System 5
Management Information System 5
 
Management Information System 4
Management Information System 4Management Information System 4
Management Information System 4
 
Object-Oriented Programming 5
Object-Oriented Programming 5Object-Oriented Programming 5
Object-Oriented Programming 5
 
Business Computer Project 3
Business Computer Project 3Business Computer Project 3
Business Computer Project 3
 
Management Information System 3
Management Information System 3Management Information System 3
Management Information System 3
 
Business Computer Project 2
Business Computer Project 2Business Computer Project 2
Business Computer Project 2
 
Object-Oriented Programming 4
Object-Oriented Programming 4Object-Oriented Programming 4
Object-Oriented Programming 4
 
Business Computer Project 1
Business Computer Project 1Business Computer Project 1
Business Computer Project 1
 
Chapter 1 Organization & MIS
Chapter 1 Organization & MISChapter 1 Organization & MIS
Chapter 1 Organization & MIS
 
Object-Oriented Programming 3
Object-Oriented Programming 3Object-Oriented Programming 3
Object-Oriented Programming 3
 
Object-Oriented Programming 2
Object-Oriented Programming 2Object-Oriented Programming 2
Object-Oriented Programming 2
 
Object-Oriented Programming 1
Object-Oriented Programming 1Object-Oriented Programming 1
Object-Oriented Programming 1
 

Recently uploaded

Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 

Recently uploaded (20)

Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 

ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน

  • 1. 1: #include <stdio.h> 2: #include <stdlib.h> 3: #include <conio.h> 4: 5: void add() { 6: int num1, num2, result; 7: 8: printf("nn"); 9: printf("Input number 1: "); 10: scanf("%d", &num1); 11: printf("Input number 2: "); 12: scanf("%d", &num2); 13: 14: result = num1 + num2; 15: 16: printf("t%d + %d = %dn", num1, num2, result); 17: } 18: 19: void subtrack() { 20: int num1, num2, result; 21: 22: printf("nn"); 23: printf("Input number 1: "); 24: scanf("%d", &num1); 25: printf("Input number 2: "); 26: scanf("%d", &num2); 27: 28: result = num1 - num2; 29: 30: printf("t%d - %d = %dn", num1, num2, result); 31: } 32: 33: void multiple() { 34: int num1, num2, result; 35: 36: printf("nn"); 37: printf("Input number 1: "); 38: scanf("%d", &num1); 39: printf("Input number 2: "); 40: scanf("%d", &num2); 41: 42: result = num1 * num2; 43:
  • 2. 44: printf("t%d * %d = %dn", num1, num2, result); 45: } 46: 47: void divide() { 48: float num1, num2, result; 49: 50: printf("nn"); 51: printf("Input number 1: "); 52: scanf("%f", &num1); 53: printf("Input number 2: "); 54: scanf("%f", &num2); 55: 56: result = num1 / num2; 57: 58: printf("t%.2f / %.2f = %.2fn", num1, num2, result); 59: } 60: 61: void menu() { 62: char c; 63: 64: do { 65: printf("n--- MAIN MENU ---n"); 66: printf("A) Additionaln"); 67: printf("S) Subtrackn"); 68: printf("M) Multiplen"); 69: printf("D) Dividen"); 70: printf("Q) Quitn"); 71: printf(" Select choice: "); 72: c = getch(); 73: 74: switch (c) { 75: case 'a': 76: add(); 77: break; 78: case 's': 79: subtrack(); 80: break; 81: case 'm': 82: multiple(); 83: break; 84: case 'd': 85: divide(); 86: break;
  • 3. 87: case 'q': 88: printf("nnGood bye!!!n"); 89: } 90: } while ((c != 'q')); 91: } 92: 93: int main() { 94: menu(); 95: system("PAUSE"); 96: return 0; 97: } 98: