问题遇到的现象和发生背景
设计一个程序,计算销售价格。某个用品店需要一个程序可以在输入商品的原始价格(OriginalPrice)和折扣率(DiscountRate)之后,计算并输出该折扣商品的最终价格(SalePrice)。
用代码块功能插入代码,请勿粘贴截图
#include <stdio.h>
void welcome();
int input(int n,int m);
int computer(int q,int n,int m);
int output(int n,int m,int q);
int main()
{
int n,m,p;
welcome();
input(n , m);
computer(q , n , m);
output(n , m , q);
}
void welcome()
{
printf("Welcome to sale price program\nThis program computes the saleprice of an item that has been discounted a certain percentage.\n");
}
int input(int n,int m)
{
printf("What is the price: ");
scanf("%i",&n);
printf("\nWhat is the percentage dicounted: ");
scanf("%i",&m);
return n,m;
}
int computer(int q,int n,int m)
{
q = n * (1 - m/100);
return q;
}
int output(int n,int m,int q)
{
printf("\npre-price was: %i",n);
printf("\nprecentage discounted was: %i",m);
printf("\nsale price is: %i",q);
}
运行结果及报错内容
Welcome to sale price program
This program computes the saleprice of an item that has been discounted a certain percentage.
What is the price: 100
What is the percentage dicounted: 10
pre-price was: 16
precentage discounted was: 449
sale price is: 0
我的解答思路和尝试过的方法
不知道为何最后是乱码
我想要达到的结果
pre-price was: 100
precentage discounted was: 10
sale price is: 90