这是按下ctrl + f9时没有显示任何错误的程序.它说按任意键继续,我这样做,然后它不运行我使用turbo c ++ 4.0,我已经保存了.c格式的文件请建议我应该做的更改来执行我的程序.
谢谢
# include <stdio.h>
# include <conio.h>
float main()
{
float l,b,r;
float circ,area,arsq,peri;
clrscr ();
printf ("Enter the length of the rectangle: ");
scanf ("%f", l);
printf ("\nEnter the breadth of the rectangle: ");
scanf ("%f", b);
printf ("\nEnter the radius of the circle: ");
scanf ("%f", r);
peri = l+b+l+b;
area = 3.14*r*r;
arsq = l*b;
circ = 3.14*2*r;
printf ("\n\nThe perimeter of the rectangle is: %f",peri);
printf ("\n\nThe area of the rectangle is: %f",arsq);
printf ("\n\nThe circumfrence of the circle is: %f",circ);
printf ("\n\nThe area of the circle is: %f",area);
getch();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
更改
scanf ("%f", l);
scanf ("%f", b);
scanf ("%f", r);
Run Code Online (Sandbox Code Playgroud)
至
scanf ("%f", &l);
scanf ("%f", &b);
scanf ("%f", &r);
Run Code Online (Sandbox Code Playgroud)
正如%f那些人scanf期望变量(float*)的地址而不是它的值.
此外,main应按标准返回int,而不是a float.