[英]Why won't my code take multiple inputs after asking to print the value of length and breadth?
#include <stdio.h>
//#include <conio.h> // Non-standard and not required!
int main()
{
float areaoc,areaor,peroc,peror,l,b,r,pi;
pi=3.14;
printf("Enter the length and breadth of rectangle: ");
scanf("%.2f %.2f",&l,&b);
printf("Enter the radius of circle: ");
scanf("%.2f",&r);
areaor=l*b;
peror=2*(l+b);
areaoc=pi*r*r;
peroc=2*pi*r;
printf("the area of rectangle is: %.2f ",areaor);
printf("the perimeter of rectangle is: %.2f ",peror);
printf("the area of circle is: %.2f ",areaoc);
printf("the perimeter of circle is: %.2f ",peroc);
return 0;
}
為什么它只讓我輸入一個值然后顯示結果?
您應該這樣執行 scanf() 語句:
scanf("%f %f",&l,&b);
然后你應該能夠將 2 個輸入值存儲到兩個給定的浮點變量中,這里是 l(length) 和 b(breadth)。
僅在 printf 語句中指定浮點數后應顯示多少個數字的 state。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.