简单的校正C程序 [英] Simple correction for a c program
本文介绍了简单的校正C程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:结果
Neen帮助一个简单的C程序
块引用>需要一个简单的修正一个C程序。该方案是假设告诉你,你的成绩,但它使返回字母k。我该怎么办?
的#include<&stdio.h中GT;
诠释的main()
{
双testValue;
焦炭getGrades;
的printf(请输入你的分数O和100之间:);
scanf函数(%LF,&安培; testValue);
的printf(你的品位%C \\ n,&安培; getGrades);
返回0;
}
焦炭getGrades(双值)
{
如果(价值> = 90)
return'A';
否则,如果(价值> = 80)
return'B';
否则,如果(价值> = 70)
return'C';
否则,如果(价值> = 60)
return'D';
return'F';
}
解决方案试试这个。
的printf(你的品位%C \\ N,getGrades(testValue));
在您的code,你永远传递比分
getGrades()
。删除字符getGrades;
的#include<&stdio.h中GT;焦炭getGrades(double值); //向前声明诠释的main()
{
双testValue;
//字符getGrades; //不需要
的printf(请输入你的分数O和100之间:);
scanf函数(%LF,&安培; testValue);
的printf(你的品位%C \\ N,getGrades(testValue));
返回0;
}
焦炭getGrades(双值)
{
如果(价值> = 90)
return'A';
否则,如果(价值> = 80)
return'B';
否则,如果(价值> = 70)
return'C';
否则,如果(价值> = 60)
return'D';
return'F';
}Possible Duplicate:
Neen help for a simple c programNeed a simple correction for a c program. The program is suppose to tell you your grade but it keeps returning the letter k. What can I do?
#include <stdio.h> int main() { double testValue; char getGrades; printf("Enter your score between o and 100:"); scanf("%lf", &testValue); printf("Your grade is %c\n", &getGrades); return 0; } char getGrades(double value) { if(value>=90) return'A'; else if(value>=80) return'B'; else if(value>=70) return'C'; else if(value>=60) return'D'; return'F'; }
解决方案Try this.
printf("Your grade is %c\n", getGrades(testValue));
In your code , you never pass the score to
getGrades()
. Remove thechar getGrades;
#include <stdio.h> char getGrades(double value); //Forward Declaration int main() { double testValue; // char getGrades; //Not Needed printf("Enter your score between o and 100:"); scanf("%lf", &testValue); printf("Your grade is %c\n", getGrades(testValue)); return 0; } char getGrades(double value) { if(value>=90) return'A'; else if(value>=80) return'B'; else if(value>=70) return'C'; else if(value>=60) return'D'; return'F'; }
这篇关于简单的校正C程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文