例2.1
/ * Output:"Programming is fun. " * / / * 注释 * /
# inclunde<stdio.h> / *编译预处理命令 * /
int main(void)
{
Printf("Programming is fun. "); / *调用 Printf()函数输入文字 * /
return 0;
}
#include <stdio.h>
int main(void)
{ printf("Programming is fun. \n"); / * 输出文字后换行 * /
printf(”Programming in C is eve more fun!\n");
return 0;
}
例2.2
#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);
}
例2.5
#include<stdio.h>
#define PRICE 20
int main()
{
int num, total;
num = 10;
total = num * PRICE;
printf("总价格为:%d\n", total);
return 0;
}
例2.6
#include<stdio.h>
int main()
{ int a, b, c;
char ch = 'A';
a=10;
b=a + ch;
scanf("%d", &c);
printf("%d,%d,%d,%c\n", a, b, c, ch);
return 0;
}