警告:可能在‘a'定义以前使用了它在main函数中 谁帮帮我啊
#include<stdio.h>intmain(void){doublea;inth,ho,l,lo;printf("pleaseenterlowerandupperi...
#include<stdio.h>
int main(void)
{
double a;
int h,ho,l,lo;
printf("please enter lower and upper integer limits:");
while(scanf("%d%d",&h,&l));
{
ho=h,lo=l;
while(h>l)
{
a=a+h*h;
h=h-1;
}
printf("the sums of the squares fron %d to %d is %.2lf",ho,lo,a);
getch();
printf("please enter lower and upper integer limits:");
}
printf("Done");
getch();
return 0;
}
不知道有谁会啊,我看了半个小时还看不出哪里出问题(我是新手,麻烦大家指教指教谢谢) 展开
int main(void)
{
double a;
int h,ho,l,lo;
printf("please enter lower and upper integer limits:");
while(scanf("%d%d",&h,&l));
{
ho=h,lo=l;
while(h>l)
{
a=a+h*h;
h=h-1;
}
printf("the sums of the squares fron %d to %d is %.2lf",ho,lo,a);
getch();
printf("please enter lower and upper integer limits:");
}
printf("Done");
getch();
return 0;
}
不知道有谁会啊,我看了半个小时还看不出哪里出问题(我是新手,麻烦大家指教指教谢谢) 展开
展开全部
a定义时应该初始化, double a = 0.0;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你没有给a赋初值。a=a+h*h;在第一次运行到这时,a的值未知;加上一个未知的值,肯定收到警告
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include<stdio.h>
int main(void)
{
double a=0.0;
int h,ho,l,lo;
printf("please enter lower and upper integer limits:");
while(scanf("%d%d",&h,&l));
{
ho=h,lo=l;
while(h>l)
{
a=a+h*h;
h=h-1;
}
printf("the sums of the squares fron %d to %d is %.2lf",ho,lo,a);
getch();
printf("please enter lower and upper integer limits:");
}
printf("Done");
getch();
return 0;
}
int main(void)
{
double a=0.0;
int h,ho,l,lo;
printf("please enter lower and upper integer limits:");
while(scanf("%d%d",&h,&l));
{
ho=h,lo=l;
while(h>l)
{
a=a+h*h;
h=h-1;
}
printf("the sums of the squares fron %d to %d is %.2lf",ho,lo,a);
getch();
printf("please enter lower and upper integer limits:");
}
printf("Done");
getch();
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询