POLITO COMPUTER SCIENCE lab numero due

**这玩意纯属于自己练习时候写的而且没写完,别介意写成啥样。
/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;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值