I am having problems with the following code:
#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;
}
The output which I am getting is :
Enter your choice- 1.Area of circle 2.Area of Square 3.Area of Rectangle 1
Enter the radius of circle.. 2
Area of circle is 0
Why am I getting 0 as output?