程序要求输入,然后不显示任何输出。 [英] Program is asking for the input and then do not shows any output.
本文介绍了程序要求输入,然后不显示任何输出。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#include<stdio.h>
main()
{
int scores[3], sum;
float avg;
printf("enter the value for scores\n");
scanf("%d\n %d\n %d\n",&scores[0],&scores[1],&scores[2]);
sum=scores[0]+scores[1]+scores[2];
avg=sum/3;
printf("The sum is :%d\n The avg is :%f\n",sum,avg);
system("pause");
}
真正的计划是:
The real program is:
#include<stdio.h>
main()
{
int scores[3],sum;
float avg;
printf("Enter Score 1 : ");
scanf("%d",&scores[0]);
printf("Enter Score 2 : ");
scanf("%d",&scores[1]);
printf("Enter Score 3 : ");
scanf("%d",&scores[2]);
sum=scores[0]+scores[1]+scores[2];
avg=sum/3;
printf("Sum is = %d\nAverage = %f\n",sum,avg);
system("pause");
我尝试过:
问题很大,我试图修剪它但输入3个输入时没有显示输出。
What I have tried:
The problem is big and I tried to trim it but it is showing no output when I enter 3 inputs.
推荐答案
它适用于我:
It works fine for me:
enter the value for scores
10
20
30
The sum is :60
The avg is :20
Sum is = 60
Average = 20
并且
Enter Score 1 : 10
Enter Score 2 : 20
Enter Score 3 : 30
Sum is = 60
Average = 20
检查您是否正在运行正确的可执行文件...并尝试摆脱系统(暂停)
行。
#include<stdio.h>
int main(void)
{
int scores[3], sum;
float avg;
printf("enter the value for scores\n");
scanf("%d%d%d",&scores[0],&scores[1],&scores[2]);
sum=scores[0]+scores[1]+scores[2];
avg=sum/3.0;
printf("The sum is :%d\n The avg is :%f\n",sum,avg);
return 0;
}
这篇关于程序要求输入,然后不显示任何输出。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文