This program I wrote has an error. It would be nice if someone can trace the error in this.
Write a complete C Program that will either display [1]Area of the Circle OR [2]Area of the Square OR [3] Area of the Triangle. Use a function for each computation or task.
Code:
#include <stdio.h>
#include <conio.h>
void main()
void aCircle()
void aSquare()
void aTriangle()
{
int rad, side, base, height, choice;
float A;
printf("[1]Area of the Circle\n");
printf("[2]Area of the Square\n");
printf("[3]Area of the Triangle\n");
scanf("%d", &choice);
switch(choice)
{
case 1: aCircle();
break;
case 2: aSquare();
break;
case 3: aTriangle();
break;
default: printf("Invalid Choice");
}
void aCircle()
{
int rad;
float A;
printf("Enter Radius of the Circle\n");
scanf("%d", &rad);
A=3.1416*rad*rad;
printf("Area of the Circle is %f", A);
}
void aSquare()
{
int side;
float A;
printf("Enter the Side of the Square\n");
scanf("%d", &side);
A=side*side;
printf("Area of the Square is %f", A);
}
void aTriangle()
{
int base, height;
float A;
printf("Enter the Base and Height\n");
scanf("%d %d", &base, &height);
A=(base*height)/2.0;
printf("Area of the Triangle %f", A);
}
}