SlideShare a Scribd company logo
1 of 13
Download to read offline
Week7
เปิดงานเดิมขึ้นมา
จากนั้นพิมพ์โค้ดเพิ่ม
#include "stdio.h"
void main()
{
char menu;
int counter;
for(counter=1;counter<=4;counter++)
{
printf("nPlease insert your order:");
scanf(" %c",&menu);
switch(menu)
{
case 'p' : printf("Papaya Saladn");
break;
case 't' : printf("Tomyam kungn");
break;
case 'i' : printf("Padthain");
break;
case 'l' : printf("Labmoon");
break;
defaul : printf("try again");
}
}
getch();
return 0;
ทาสูตรคูณ
#include "stdio.h"
void main()
{
int counter;
for(counter = 1;counter<=12;counter++)
{
printf("2 * %d = %dn",counter,counter*2);
}
printf("ngood bye");
getch();
return 0;
}
การใช้ While
#include "stdio.h"
void main()
{
int counter;
counter = 1;
while(counter<=12)
{
printf("2 * %d = %dn",counter,counter*2);
counter++;
}
printf("ngood bye");
getch();
return 0;
}
การใช้ do while
#include "stdio.h"
void main()
{
int counter;
counter =1;
do
{
printf("2* %d = %dn",counter,counter*2);
counter++;
}while(counter<=12);
printf("good bye");
getch();
return 0;
}
กาหนดแม่เอง
#include "stdio.h"
void main()
{
int counter,counter1,number;
for(counter1=1;counter1<=5;counter1++)
{
printf("please insert to number: ");
scanf("%d",&number);
for(counter=1;counter<=12;counter++)
{
printf("%d * %d = %dn",number,counter,number*counter);
}
}
printf("good byen");
getch();
return 0;
}
ทดสอบ
สร้างโปรแกรมนับเฉพาะเลขคู่ 2 4 6 8 10 โดยใช้ for
#include "stdio.h"
void main()
{
int counter,number;
for(counter=2;counter<=10;counter=counter+2)
{
printf("%dn",counter);
}
printf("ngood bye");
getch();
return 0;
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Array
#include "stdio.h"
void main()
{
int a[5];
a[0]=1;
a[1]=2;
a[2]=3;
a[3]=4;
a[4]=5;
printf("%d %d %d %d %d",a[0],a[1],a[2],a[3],a[4]);
getch();
return 0;
}
การเลือกแสดง
#include "stdio.h"
void main()
{
int a[5];
a[0]=1;
a[1]=2;
a[2]=3;
a[3]=4;
a[4]=5;
printf("%d %d ",a[2],a[4]);
getch();
return 0;
}
แยกชื่อ
#include "stdio.h"
void main()
{
char name[10];
printf("Please insert your name:");
scanf("%s",&name);
printf("You are spell %s n ");
printf("%c + %c + %c + %c + %c + %c + %c + %c + %c +
%c",name[0],name[1],name[2],name[3],name[4],name[5],name[6],name[7],name[8],name[9]);
getch();
return 0;
}
ตาราง
#include "stdio.h"
#include "conio.h"
void main()
{
int table[9][9],i,j,x;
for(i=1; i<=9; i++)
{
for (j=1; j<=9; j++)
{
x = i-1;
table[x][j-1]= i*j;
}
}
printf("* |t1t2t3t4t5t6t7t8t9n");
printf("----------------------------------------------------------------------------n");
for(i=0;i<9;i++)
{
printf("%d |t",i+1);
for (j=0;j<9; j++)
{
printf("%dt",table[i][j]);
}
}
getch();
return 0;
}

More Related Content

What's hot

Piaget's Psychoanalysis
Piaget's PsychoanalysisPiaget's Psychoanalysis
Piaget's Psychoanalysis
Tamba Komba
 
第4章 存储器管理实验
第4章  存储器管理实验第4章  存储器管理实验
第4章 存储器管理实验
guest332a57
 
JAVASCRIPT NÃO-OBSTRUTIVO com jQuery
JAVASCRIPT NÃO-OBSTRUTIVO com jQueryJAVASCRIPT NÃO-OBSTRUTIVO com jQuery
JAVASCRIPT NÃO-OBSTRUTIVO com jQuery
Zigotto Tecnologia
 

What's hot (15)

Algoritmos ensambladores
Algoritmos ensambladoresAlgoritmos ensambladores
Algoritmos ensambladores
 
Add tab jtabbedpane
Add tab jtabbedpaneAdd tab jtabbedpane
Add tab jtabbedpane
 
Large scale machine learning projects with r suite
Large scale machine learning projects with r suiteLarge scale machine learning projects with r suite
Large scale machine learning projects with r suite
 
Paycheck Calculator Code - Intro to Programming Logic
Paycheck Calculator Code - Intro to Programming LogicPaycheck Calculator Code - Intro to Programming Logic
Paycheck Calculator Code - Intro to Programming Logic
 
Piaget's Psychoanalysis
Piaget's PsychoanalysisPiaget's Psychoanalysis
Piaget's Psychoanalysis
 
01 list using array
01 list using array01 list using array
01 list using array
 
C언어 스터디 강의자료 - 1차시
C언어 스터디 강의자료 - 1차시C언어 스터디 강의자료 - 1차시
C언어 스터디 강의자료 - 1차시
 
Linear search
Linear searchLinear search
Linear search
 
Prime number program in c
Prime number program in cPrime number program in c
Prime number program in c
 
Parsec
ParsecParsec
Parsec
 
JavaOne2010 Groovy/Spring Roo
JavaOne2010 Groovy/Spring RooJavaOne2010 Groovy/Spring Roo
JavaOne2010 Groovy/Spring Roo
 
6. CodeIgniter copy2
6. CodeIgniter copy26. CodeIgniter copy2
6. CodeIgniter copy2
 
Phpbase
PhpbasePhpbase
Phpbase
 
第4章 存储器管理实验
第4章  存储器管理实验第4章  存储器管理实验
第4章 存储器管理实验
 
JAVASCRIPT NÃO-OBSTRUTIVO com jQuery
JAVASCRIPT NÃO-OBSTRUTIVO com jQueryJAVASCRIPT NÃO-OBSTRUTIVO com jQuery
JAVASCRIPT NÃO-OBSTRUTIVO com jQuery
 

Similar to Week7

C basics
C basicsC basics
C basics
MSc CST
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
Mainak Sasmal
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
Mainak Sasmal
 

Similar to Week7 (20)

C programms
C programmsC programms
C programms
 
C basics
C basicsC basics
C basics
 
C programming
C programmingC programming
C programming
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
 
stack.pptx
stack.pptxstack.pptx
stack.pptx
 
Practical File of C Language
Practical File of C LanguagePractical File of C Language
Practical File of C Language
 
5 c control statements looping
5  c control statements looping5  c control statements looping
5 c control statements looping
 
C programming
C programmingC programming
C programming
 
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
 
C file
C fileC file
C file
 
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
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
 
C
CC
C
 
C Programming Lab.pdf
C Programming Lab.pdfC Programming Lab.pdf
C Programming Lab.pdf
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
 
Double linked list
Double linked listDouble linked list
Double linked list
 
06 1 조건문
06 1 조건문06 1 조건문
06 1 조건문
 
C lab programs
C lab programsC lab programs
C lab programs
 

More from Modell Jinayang (20)

Week15
Week15Week15
Week15
 
Week14
Week14Week14
Week14
 
Week13
Week13Week13
Week13
 
Week12
Week12Week12
Week12
 
Week11
Week11Week11
Week11
 
Week8
Week8Week8
Week8
 
Week7
Week7Week7
Week7
 
Week6
Week6Week6
Week6
 
Week5
Week5Week5
Week5
 
Week4
Week4Week4
Week4
 
Week3
Week3Week3
Week3
 
Week2
Week2Week2
Week2
 
Week15
Week15Week15
Week15
 
Week14
Week14Week14
Week14
 
Week13
Week13Week13
Week13
 
Week6
Week6Week6
Week6
 
Week5
Week5Week5
Week5
 
Week4
Week4Week4
Week4
 
Week3
Week3Week3
Week3
 
Week2
Week2Week2
Week2
 

Recently uploaded

Recently uploaded (20)

This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
latest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answerslatest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answers
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health Education
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 

Week7