2005/Aug/02

การใช้ภาษา C

ตัวอย่างแรก

#include<stdio.h> /*ส่วนหัว*/

#include<conio.h>/*ฟังก์ชันสำหรับเคลียหน้าจอ*/

void main()

{

cluscr();/*สำหรับเคลียหน้าจอให้ว่าง*/

printf("Hello, What your name\n");/*สำหรับแสดงข้อความออกทาง Input*/

getch();/*แสดงข้อความให้เรเห็น*/

}

การใช้ FOR

ตัวอย่างโปรแกรมสูตรคูณ

#include<stdio.h>

#include<conio.h>

viod main()

{

int a,b,i; /*ประกาศตัวแปร*/

clrscr();

printf("Enter number: "); /*แสองข้อความให้กรอกตัวเลข*/

scanf("%d",&a);/*รับตัวเลขมาเก็บไว้ในตัวแปร a*/

for(i=0 ; i<13 ; i++);/*ใช้คำสั่ง for ในการวนรอบ*/

b = a*i;/*คำนวณ*/

printf("%d x %d = %d \n",a,i,b);/*แสดงผลการคำนวณ*/

getch();

}

ตัวอย่างการหาพื้นที่วงกลม

/* Area Circle Program */

#include<stdio.h>

#include<conio.h>

void main()

{

float r,area;

clrscr();

printf("Enter Radial = ");

scanf("%f",&r);

area = 3.14*r;

printf("Area Circle = %f",area);

getch();

}

ตัวอย่างการหาพื้นที่สามเหลี่ยม

#include<stdio.h>

#include<conio.h>

void main()

{

float higt,bass,area;

clrscr();

printf("Enter High Triangle = ");

scanf("%f",&high);

ptintf("Enter Bass Triangle = ");

scanf("%s",&bass);

area = 0.5*high*bass;

printf("Area Triangle %f",area);

getch();

}


NEXT>




Comment

Comment:

Tweet


#193 by (46.165.225.198|46.165.225.198) At 2014-07-18 01:19,
#192 by (95.211.192.231|95.211.192.231) At 2014-07-17 08:46,
#191 by (5.79.73.142|5.79.73.142) At 2014-07-17 08:41,
#190 by (46.165.225.198|46.165.225.198) At 2014-07-17 06:50,
#189 by (95.211.192.231|95.211.192.231) At 2014-07-15 07:57,
#188 by (95.211.192.231|95.211.192.231) At 2014-07-11 10:45,
#187 by (78.46.62.25|78.46.62.25) At 2014-07-10 05:12,
#186 by (78.46.62.25|78.46.62.25) At 2014-07-10 05:11,
#185 by (95.211.192.231|95.211.192.231) At 2014-07-09 07:25,
#184 by (37.239.46.2|37.239.46.2) At 2014-07-08 05:14,
#183 by (5.79.73.142|5.79.73.142) At 2014-07-06 22:05,
#182 by (95.211.192.231|95.211.192.231) At 2014-07-06 17:17,
#181 by (5.79.73.142|5.79.73.142) At 2014-07-05 10:48,
#180 by (95.211.192.231|95.211.192.231) At 2014-07-05 08:34,
Farmville farms even include free gift that is eakcebkdkgedadfa
#179 by (188.237.180.55|95.211.218.103, 188.237.180.55) At 2014-07-04 05:17,
#178 by (95.211.192.231|95.211.192.231) At 2014-07-03 05:57,
#177 by (5.79.73.142|5.79.73.142) At 2014-07-03 04:13,
#176 by (95.211.192.231|95.211.192.231) At 2014-07-02 06:58,
#175 by (37.239.46.10|37.239.46.10) At 2014-07-02 05:20,
#174 by (37.239.46.10|37.239.46.10) At 2014-07-02 05:19,
#173 by (5.79.73.142|5.79.73.142) At 2014-07-01 12:27,
#172 by (95.211.192.231|95.211.192.231) At 2014-07-01 11:05,
#171 by (186.251.170.2|85.17.205.213, 186.251.170.2) At 2014-06-30 05:53,
#170 by (186.251.170.2|85.17.205.213, 186.251.170.2) At 2014-06-30 05:51,
#169 by (5.79.73.142|5.79.73.142) At 2014-06-29 17:37,
#168 by (5.79.73.142|5.79.73.142) At 2014-06-29 01:37,
#167 by (95.211.192.231|95.211.192.231) At 2014-06-28 10:23,
#166 by (5.79.73.142|5.79.73.142) At 2014-06-27 10:17,
#165 by (5.79.73.142|5.79.73.142) At 2014-06-27 03:47,
#164 by (95.211.192.231|95.211.192.231) At 2014-06-27 01:23,
#163 by (5.79.73.142|5.79.73.142) At 2014-06-26 14:50,
#162 by (95.211.192.231|95.211.192.231) At 2014-06-25 16:30,
#161 by (5.79.73.142|5.79.73.142) At 2014-06-23 21:34,
#160 by (95.211.192.231|95.211.192.231) At 2014-06-23 09:53,
#159 by (5.79.73.142|5.79.73.142) At 2014-06-22 17:56,
#158 by (95.211.192.231|95.211.192.231) At 2014-06-21 05:36,
#157 by (95.211.192.231|95.211.192.231) At 2014-06-21 01:48,
#156 by (5.79.73.142|5.79.73.142) At 2014-06-21 00:16,
#155 by (5.79.73.142|5.79.73.142) At 2014-06-20 06:57,
#154 by (5.79.73.142|5.79.73.142) At 2014-06-19 20:42,
#153 by (95.211.192.231|95.211.192.231) At 2014-06-19 16:23,
#152 by (5.79.73.142|5.79.73.142) At 2014-06-19 11:57,
#151 by (5.79.73.142|5.79.73.142) At 2014-06-18 17:24,
#150 by (95.211.192.231|95.211.192.231) At 2014-06-18 13:58,
Very nice site! cheap goods
#149 by (187.188.195.66|95.211.218.103, 187.188.195.66) At 2014-06-17 05:28,
I'm glad that it turned out so effectively and I hope it will continue in the future because it is so worthwhile and meaningful to the community. kdgdbgddcegaeceb
#148 by (59.8.134.46|59.8.134.46) At 2014-06-16 13:03,
#147 by (175.197.48.45|175.197.48.45) At 2014-06-11 14:23,
#146 by (175.197.48.45|175.197.48.45) At 2014-06-11 14:22,
#145 by (175.197.48.45|175.197.48.45) At 2014-06-11 14:21,
#144 by (190.128.149.34|148.251.91.38, 190.128.149.34) At 2014-06-09 13:17,