C Program to find area and perimeter using function | C Programming Language

#include <stdio.h>
int area (int,int);
int main()
{
int len, bred, a;
printf("Enter length of rectangle");
scanf("%d",&len);
printf("Enter breadth of rectangle:");
scanf("%d",&bred);
a=area(len,bred);
printf("The area is %d",a);
return 0;
}
int area(int a, int b)
{int area;
area=a*b;
return area;
}

OUTPUT

C program to find area using function.


#include<stdio.h>

int perimeter (int,int);

int main()

{

int len, bred, p;

printf("Enter length of rectangle:\n");

scanf("%d",&len);

printf("Enter breadth of rectangle:\n");

scanf("%d",&bred);

p=perimeter(len,bred);

printf("The perimeter is %d.",p);

return 0;

}

int perimeter(int a, int b)

{int perimeter;

perimeter=2*(a+b);

return perimeter;

}

OUTPUT

#include<stdio.h>

int perimeter (int,int);

int main()

{

int len, bred, p;

printf("Enter length of rectangle:\n");

scanf("%d",&len);

printf("Enter breadth of rectangle:\n");

scanf("%d",&bred);

p=perimeter(len,bred);

printf("The perimeter is %d.",p);

return 0;

}

int perimeter(int a, int b)

{int perimeter;

perimeter=2*(a+b);

return perimeter;

}

OUTPUT

C program to find perimeter using function
Share To:

Arogya Thapa Magar

Post A Comment:

0 comments so far,add yours