所以我正在尝试编写一个函数,它接收一个浮点值,返回一个浮点值,并用 printf 显示在 main 中。我不断收到相同的错误:markup2.c:58:错误:“GetPrice”的类型冲突 markup2.c:46:错误:“GetPrice”的先前隐式声明在这里
我在哪里犯错?我已经尝试过对涉及 GetPrice 的所有内容进行类型转换,但仍然没有运气。有人可以解释我做错了什么吗?
#include<stdio.h>
// define the constant MARKUP as float value 0.1
#define MARKUP 0.1
int main()
{
// declare variables
char proceed;
float value;
float markupValue;
// display welcome message to user and inform them of markup rate
printf("\nThank you for using Chad Hammond's markup calculator.\n");
printf("The current markup rate is %.1f%c.\n",MARKUP*100,'%');
// ask user if they want to perform a markup
printf("Would you like to markup an item? y/n:\n");
scanf("%c", &proceed);
// if yes, proceed to next step
if(proceed == 'y')
{
// prompt user for the price of item to be marked up
printf("Please enter a wholesale value to markup: ");
scanf("%f", &value);
// display input back to user
printf("The wholesale value you entered was: %c%.2f\n",'$', value);
markupValue = (value*MARKUP);
// display amount of increase
printf("The dollar amount of this increase will be: %c%.2f\n",'$', markupValue);
// display total price after increse
printf("The price for this item after markup is: %c%.2f\n",'$', (float)GetPrice(value));
}else
// if user did not want to markup an item, belittle them with sarcasm
printf("Well, if you didn't want to markup an item you should have just used a Ti-83 and left me alone!\n\n");
// display exit message
printf("Thank you for using HammondInstruments Markup Calculator, goodbye.\n");
// return that program has completed
return 0;
}
float GetPrice(float value)
{
float output;
value += value*MARKUP;
output = value;
return (float)output;
}