我在使用以下代码时遇到问题:
#include<stdio.h>
#include<conio.h>
float area_crcl(int);
float area_rect(int,int);
void main()
{
int n,a,b,r;
float area;
clrscr();
printf("\nEnter your choice-\n1.Area of circle\n2.Area of Square\n3.Area of Rectangle\n");
scanf("%d",&n);
switch(n)
{
case 1:printf("\nEnter the radius of circle..\n");
scanf("%d",&r);
area=area_crcl(r);
printf("\nArea of circle is %d\n",area);
break;
case 2:printf("\nenter the edge of square\n");
scanf("%d",&a);
area=area_rect(a,a);
printf("\nArea of square is %d\n",area);
break;
case 3:printf("\nenter the lenght n breadth of rectangle\n");
scanf("%d%d",&a,&b);
area=area_rect(a,b);
printf("\nArea of rectangle is %d\n",area);
break;
default:printf("\nU entered wrong choice..\n");
}
getch();
}
float area_crcl(int r)
{
float area;
area=3.14*r*r;
return area;
}
float area_rect(int a,int b)
{
float area;
area=a*b;
return area;
}
我得到的输出是:
输入您的选择 - 1.圆的面积 2.正方形的面积 3.矩形的面积 1
输入圆的半径.. 2
圆的面积为 0
为什么我得到 0 作为输出?