Sunday 12 January 2014

Program of Function in c.

      /* program to create a function area() to print the area of rectangle*/
#include<stdio.h>
void main()
{
int l,b,a;
int area(int l, int b);
printf("enter the length & breadth");
scanf("%d%d",&l,&b);
a=area(l,b);
printf("area=%d",a);
}
int area(int x, int y)
{
int r;
r=x*y;
return(r);
}

      /* program to create a function area() to print the area of circle*/
#include<stdio.h>
void main()
{
int r;
float a;
float area(int r);
printf("enter the radius of circle");
scanf("%d",&r);
a=area(r);
printf("area=%f",a);
}
float area(int r1)
{
int s;
s=3.14*r1*r1;
return(s);
}

No comments:

Post a Comment