Program of UDF with choice to access the program menu in C Language

#include<stdio.h>
#include<conio.h>
#define pi 3.14

//user defined functions
void aos();
void aoc();
void aor();
void aot();
void voc();
void vos();
void vocu();
void voco();
void pos();
void poc();
void por();
void pot();


void main()
{
clrscr();
int n,i,m,a,b;
for(i=0;n!=0;i++)
{
clrscr();
printf("\nMenu Of Program\n");
printf("0.Exit\n1.Area\n");
printf("2.Volume\n3.Perimeter\n");
printf("Enter your choice=");
scanf("%d",&n);
clrscr();
switch(n)
{
case 1:
printf("\t\nArea\n");
printf("1.Square\n");
printf("2.Circle\n");
printf("3.Rectangle\n");
printf("4.Triangle\n");
printf("Enter your Choice=");
scanf("%d",&m);
clrscr();
switch(m)
{
case 1:aos();
getch();
break;
case 2:aoc();
getch();
break;
case 3:aor();
getch();
break;
case 4:aot();
getch();
break;
default:
printf("Invalid no.");
getch();
break;
}
break;
case 2:
printf("\t\nVolume\n");
printf("1.Cube\n");
printf("2.Sphere\n");
printf("3.Cuboid\n");
printf("4.Cone\n");
printf("Enter your choice=");
scanf("%d",&a);
clrscr();
switch(a)
{
case 1:voc();
getch();
break;
case 2:vos();
getch();
break;
case 3:vocu();
getch();
break;
case 4:voco();
getch();
break;
default:
printf("Invalid no.");
getch();
break;
}
break;
case 3:
printf("\t\nPerimeter\n");
printf("1.Square\n2.Circle\n3.Rectangle\n4.triangle\n");
printf("Enter your choice=");
scanf("%d",&b);
clrscr();
switch(b)
{
case 1:pos();
getch();
break;
case 2:pos();
getch();
break;
case 3:por();
getch();
break;
case 4:pot();
getch();
break;
default:
printf("Invalid no.");
getch();
break;
}
break;
default:
printf("Invalid no.");
break;
}
}
clrscr();
getch();
}

void aos()
{
int l,a;
printf("Length of Square=");
scanf("%d",&l);
a=l*l;
printf("Area of Square=%d",a);
}
void aoc()
{ int r,a;
printf("Radius of Circle=");
scanf("%d",&r);
a=pi*r*r;
printf("Area of Circle=%d",a);

}
void aor()
{
int l,b,a;
printf("Length of Rectangle=");
scanf("%d",&l);
printf("Breadth of Rectangle=");
scanf("%d",&b);
a=l*b;
printf("Area of Rectangle=%d",a);
}
void aot()
{
int b,h,a;
printf("Base of triangle=");
scanf("%d",&b);
printf("Height of Triangle=");
scanf("%d",&h);
a=(b*h)/2;
printf("Area of Triangle=%d",a);
}
void voc()
{
int l,v;
printf("Length of Cube=");
scanf("%d",&l);
v=l*l*l;
printf("Volume of Cube=%d",v);
}
void vos()
{
int r,v;
printf("Radius of Sphere=");
scanf("%d",&r);
v=(4*r*r*r)/3;
printf("Volume of Sphere=%d",v);
}
void vocu()
{
int l,b,h,v;
printf("Length of Cuboid=");
scanf("%d",&l);
printf("Breadth of Cuboid=");
scanf("%d",&b);
printf("Height of Cuboid=");
scanf("%d",&h);
v=l*b*h;
printf("Volume of Cuboid=%d",v);
}
void voco()
{
int r,h,v;
printf("Radius of Cone=");
scanf("%d",&r);
printf("Height of Cone=");
scanf("%d",&h);
v=(r*r*h)/3;
printf("Volume of Cone=",v);
}
void pos()
{
int l,p;
printf("Length of Square=");
scanf("%d",&l);
p=4*l;
printf("Perimeter of Square=%d",p);
}
void poc()
{
int r,p;
printf("Radius of Square=");
scanf("%d",&r);
p=2*pi*r;
printf("Perimeter of Circle=%d",p);
}
void por()
{
int l,b,p;
printf("Length of Rectangle=");
scanf("%d",&l);
printf("Breadth of Rectangle=");
scanf("%d",&b);
p=2*(l+b);
printf("Perimeter of Rectangle=%d",p);
}
void pot()
{
int a,b,c,p;
printf("Enter 1st Side=");
scanf("%d",&a);
printf("Enter 2nd Side=");
scanf("%d",&b);
printf("Enter 3rd Side=");
scanf("%d",&c);
p=a+b+c;
printf("Perimeter of Triangle=%d",p);
}




No comments

Post your comments

Powered by Blogger.