C语言程序中所用到的每一个常量、变量和函数等程序的基本操作对象都有一种数据类型与之相联系。
数据类型
基本类型:整型、字符型、实型(浮点型)。
构造类型:数组类型、结构体类型、共用体类型、枚举类型。
指针类型。空类型。
常量是在程序执行过程中,其
#include<stdio.h>
#define PI 3.14159
void main()
{
int r;
float v, f;
r = 2;
v = 4.0 * PI * r * r * r / 3.0;
f = 4.0 * PI * r * r;
printf("体积为:%f,表面积:%f\n" ,v,f);
}
#include<stdio.h>
#define PRICE 20
int main()
{
int num, total;
num = 10;
total = num * PRICE;
printf("总价格为:%d\n", total);
return 0;
}
#include<stdio.h>
int main()
{
int a, b, c;
char ch = 'A';
a = 10;
b = a + ch;
scanf_s("%d", &c);
printf("%d,%d,%d,%c\n", a, b, c, ch);
return 0;
}
#include<stdio.h>
int main()
{
int a, b, c, d;
unsigned long e;
a = 5; b = 6; e = 10;
c = a + e;
d = b + e;
printf("c=%d,d=%d\n", c, d);
return 0;
}
#include<stdio.h>
int main()
{
short int a, b;
a = 32767;
b = a + 1;
printf("a=%d,b=%d\n", a, b);
return 0;
}
#include<stdio.h>
int main()
{
float a = 1234.56789;
double b = 1234.567895678;
printf("a=%f,b=%f\n", a, b);
return 0;
}
include<stdio.h>
int main()
{
char cl,c2;
cl = 'A';
c2 = 65;
printf("%c,%c\n",cl, c2);
printf("%d,%d\n", cl, c2);
return 0;
}
#include<stdio.h>
int main()
{
char cl, c2;
cl = 'A';
c2 = 'B';
cl = cl + 32;
c2 = c2 + 32;
printf("%c,%c\n", cl, c2);
printf("%d,%d\n", cl, c2);
return 0;
}
#include<stdio.h>
int main()
{
int number, a ,b, c;
number = 123;
printf("输入的3位数为:%d\n", number);
a = number / 100;
b =(number-a * 100) / 10;
c = number%10;
printf("反序数是:%d%d%d\n", c, b, a);
return 0;
}
#include<stdio.h>
int main()
{
int i,j = 7;
float k = 5;
i = (j = j + 2, j/k);
printf("i=%d\n", i);
return 0;
}
#include<stdio.h>
int main()
{
printf("char类型占%d字节\n", sizeof(char));
printf("short int类型占%d字节\n", sizeof(short int));
printf("int类型占%d字节\n", sizeof(int));
printf("float类型占%d字节\n", sizeof(float));
printf("double类型占%d字节\n", sizeof(double));
return 0;
}
#include <stdio.h>
int main()
{
int a, b;
a = sizeof(3 + 5.0);
b = sizeof 3 + 5.0;
printf("%d,%d,%d\\", a, b, sizeof("china"));
return 0;
}
#include <stdio.h>
int main()
{
int a = 3, b = 4;
float c;
c = (float)(a + b) / 2;
printf("c=%f\n", c);
return 0;
}