More Related Content
นางสาวกัญญารัตน์ คิดในทางดี นางสาวอรอนงค์ เกตุดาว รหัสนิสิต 59170038 กลุ่ม 1 นางสาวภูริชา พลนิกร-59170111-กลุ่ม1-งานเดี่ยว นางสาว จรัญญา-กฤตย์ณัชช์-59170236-กลุ่ม-1 Viewers also liked (20)
Tasawuf perbandingan dzauq dan syurb Alan Resume Release Management 16NOV2016 552_rachel_bowe_Project Proposal Draft Final Cuidemos nuestros pensamientos Museo de barquisimeto (1) Manejo odontologico del paciente hipertenso FlorenceJenna_Dissertation Los medios de comunicacion CHERISE MARTIN FINaL 1809856 Fraude de Javier Duarte, ex gobernador de Veracruz Similar to Dev c (20)
ชื่อนางสาวอรยา กรดเครือ รหัสนิสิต 59670118 กลุ่ม 3301 ชื่อนางสาวรัตนาวลี ติมุลา รหัสนิสิต 59670108 กลุ่ม 3301 ชื่อนางสาวรัตนาวดี ติมุลา รหัสนิสิต 59670107 กลุ่ม 3301 ชื่อนางสาวรัตนาวดี ติมุลา รหัสนิสิต 59670107 กลุ่ม 3301 Slide unit1 พื้นฐานภาษาซี Dev c
- 1. Week 1
โชว์เลขที่ห่างกันอยู่ 4 จานวน แต่ไม่เกิน 10
เฮดชาร์ทหลัก ๆ คือ
#include “stdio.h”
void main()
ไฟล์นามสกุล .h เรียกว่า Header file หรือไฟล์ส่วนหัวที่มีการประกาศรายละเอียดของคาสั่งในภาษา C
int คือการรับค่าจานวนเต็ม
เมื่อเขียนโปรแกรม
#include “stdio.h”
void main()
{
int f;
for(f=1;f <=10; f=f+4)
{
- 4. Week 2
หาปริมาตรสี่เหลี่ยม
#include <stdio.h>
void main()
{
float w1,w2,h,area;
printf("Please insert side1:");
scanf("%f",&w1);
printf("Please insert side2:");
scanf("%f",&w2);
printf("Please insert to Height:");
scanf("%f",&h);
area = 0.5 *(w1 +w2) *h;
- 5. printf("Area of trapezoid side:%f side:%f and Height:%f is Area:%f",w1,w2,h,area);
getch();
return0;
}
ใช้ float เพราะเป็นเลขทศนิยม
เมื่อคำนวณออกมำจะได้ผลดังนี้
- 9. 0.5 คือ ½ ตามสูตรการหา พื้นที่ของสามเหลี่ยมคือ ½ x ฐาน x สูง
ใช้float เพราะเป็นเลขทศนิยม
- 13. Week 5
ใช้ Char บวกเลข
#include "stdio.h"
void main()
{
char ch1 = 'g';
char ch2 = 'k';
printf("ch1:%d+ ch2:%d= %d",ch1,ch2,ch1+ch2);
if(ch2 > ch1)
{
printf("nCh2more than ch1");
}
printf("nGoodbye");
- 16. else if((score >=70)&&(score<=74))
printf("Youare Grade B");
else if((score >=65)&&(score<=69))
printf("Youare Grade C+");
else if ((score >= 60)&&(score <= 64))
printf("Youare Grade C");
else if ((score >= 55)&&(score <= 59))
printf("Youare Grade D+");
else if ((score >= 50)&&(score <= 54))
printf("Youare Grade D");
else
printf("Youare Grade F");
printf("nGoodbye");
getch();
return 0;
}
- 19. case 'p':printf("Papayasalad 120");
break;
case 'c':printf("Chicken Grill 500");
break;
case 't':printf("Tomyumboneyoung 180");
break;
case 's' : printf("Stickyrice 90");
break;
default : printf("nTryagain");
}
}
printf("n--------------^_^----------------");
getch();
return 0;
}
เลือกรายการอาหาร สั่งอาหาร ใช้ switch case
ตามเงื่อนไข ถ้าต้องการ ส้มตา ให้พิมพ์ตัว P
- 21. #include "stdio.h"
void main()
{
int counter,number,counter1;
for(counter1=1;counter1<=5;counter++)
{
printf("Please insert Number:");
scanf("%d",&number);
for(counter=1;counter<=12;counter++)
{
printf("%dx%d =%dn",number,counter,number * counter);
}
}
printf("nGoodbye");
getch();
return 0;
}
ใช้int เพราะรับค่าที่เป็นจานวนเต็ม
- 26. กลับตัวหนังสือใช้ array
#include "stdio.h"
#include "conio.h"
#define MAX_VALUE50
void main()
{
int i;
char word[MAX_VALUE];
printf("Enteryour word:");
gets(word);
printf("Reverse ofyourword is:");
for(i=strlen(word)-1;i>=0;i--)
{
printf("%c",word[i]);
}
getch();
return 0;
}
- 28. ใช้ array ทาสูตรคูณเป็นตารางมี คอลัม
#include"stdio.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;
}
}