**这玩意纯属于自己练习时候写的而且没写完,别介意写成啥样。
/Write a program that defines two integer variables called var1, var2.The
program will 写一个C语言的程序定义两个变量:var1和var2:
a.Assign the following values to variables defined
接下来这两个数字的数值已经确定:
• var1 25
• var2 - 53
b.Without using a third variable, exchange the values of the variables
var1 and var2
不设立第三个变量,交换这两个数值/
#include<stdio.h>
int main()
{
int var1 = 25, var2 = -53;
printf("var1=%d,var2=%d\n", var1, var2);
var1 = var1 + var2;
var2 = var1 - var2;
var1 = var1 - var2;
printf("var1=%d,var2=%d\n", var1, var2);
return 0;
}
Write a program that defines three real variables(float) called price, tax,
and receipt, and写一个C语言编程,定义三个单位:price,tax,receipt(用float)定义:
a.Assign values chosen by the programmer to price and tax
编程者任选price和tax的数值输入‘;
b.Based on these data, calculate the price inclusive of taxes
(price + price * tax / 100) and save it in the variable receipt.
计算后保存在receipt中。
#include<stdio.h>
int main()
{
float receipt,tax, price;
printf("pls int the tax and price!\n");
scanf("%f %f",&price,&tax);
receipt = price + price * tax / 100;
printf("receipt is %f\n",receipt);
return 0;
}