程序设计与c语言
#include <stdio.h>
int main()
{
int a, b, t;/定义所用的变量/
a = 3; b = 5;/给变量赋值/
t = a;/变量a的值存入变量t中/
a = b;/变量b的值赋予变量a/
b = t;/变量t的值赋予变量b/
printf("%d,%d", a, b);/输出交换后的变量的值/
return 0;
}
/Output:“Programming is fun.”/ /注释/
#include<stdio.h> /编译预处理命令/int main(void) { printf(“Programming is fun.”); /调用printf()函数输出文字/ return 0;}
#include <stdio.h>
int main()
{
int a, b, t;/定义所用的变量/
a = 3; b = 5;/给变量赋值/
t = a;/变量a的值存入变量t中/
a = b;/变量b的值赋予变量a/
b = t;/变量t的值赋予变量b/
printf("%d,%d", a, b);/输出交换后的变量的值/
return 0;
}
#include <stdio.h>
#define PRICE 20
int main()
{
int num, total;/num表示购买商品的数量,total表示总价款/
num = 10;
total = num * PRICE;/PRICE是符合常量,表示单价20/
printf(“总价款为:%d\n”,total);
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;
}