Seal of Good Local Governance (SGLG) 2024Final.pptx
การกำหนดตัวแปร
1. - .............................................................. 20 2553
F
F
..........................................................................................................................................................................
(variables)
FF F F F F
F F F 5 (char) (int)
(float) 2 F (double) F F F (void) F
F F F F F
char ,F 1 -128 128
int 2 -32768 32767
float 4 3.4E-38 3.4E+38
double 8 1.7E-308 1.7E+308
1. F F F underscore F
2. F underscore
3. F ( F F compiler F 31 F F
)
F
4. F 33
asm auto break case char const continue default do double else enum extern float for goto if
int long register return short signed sizeof static struct switch typedef union unsigned void
volatile while
5.
2. - .............................................................. 20 2553
F F F
F
F F F F F
F F F = F F F
char name, day = 'S' , surname[20] ="Kodedee";
int x=5 ,y,z[100]; float a=5.00 ,b,c; double k=1.234567, m ;
F F F F
F
1. name char .
2. num1 int .
3. sum float .
4. score double .
5. age int .
3. - .............................................................. 20 2553
(operator)
F F F
F (mathematical operators)
F F
+ 2+5 F7
- 7-4 F3
* 2*6 F 12
/ 8/2 F4
% 9%4 F1
F (relational operators)
F F
< F F 2<3 F (1)
> F 2>3 F (false)(0)
<= F F F 2<= 3 F (true)
>= F F 2>= 3 F (false)
== F 4==4 F (true)
!= F F 2!= 2 F (false)
(logical operators)
F F
&& (AND) (2<3)&&(3>1) F
|| (OR) (2>3)||(4<1) F
(false)
! (NOT)
F !(2> 3) F (true)
4. - .............................................................. 20 2553
F 1 F
F
F =5
F =4
= 0.5 x x
F
F
F
F
F F example1.c
/* program example1.c */
#include <stdio.h>
int lengt , high ;
float area;
main()
{
lengt = 5;
high = 4;
area = 0.5 * lengt * high ;
printf("tDetermination of triangle arean");
printf("tThe length of triangle = %dn ",lengt);
printf("tThe height of triangle = %dn ",high);
printf("tThe area of triangle = %.2fn",area);
}
5. - .............................................................. 20 2553
F 2 2.00 F
FF F F F F
F F example2.c
/* program example2.c */
#include <stdio.h>
#define pi 3.14
float radius,area;
main()
{
radius = 2.00;
area = pi * radius * radius;
printf("tArea of circlen ");
printf("tRadius = %.2f n",radius);
printf("tArea = %.2f n",area);
}