69.8k views
14 votes
Write a c program to find area of rectangle using user defined function.​

User Sevenever
by
3.3k points

2 Answers

9 votes

CODE

#include <stdio.h>

// User-defined function to calculate the area of a rectangle.

int rectangleArea(int length, int width)

{

// Returns an integer value

return length * width;

}

int main()

{

// Declare the variable

int area;

//Input the length and width of the rectangle

area = rectangleArea(6, 19);

// Print the area

printf("%d", area);

return 0;

}

EXPLANATION

Main and rectangleArea are user-defined functions.

The area is length times width.

Input two integers to call the function to see the area.

User Pete Scott
by
4.4k points
11 votes

Answer:

// C Program to Find Area of Rectangle

#include <stdio.h>

int main() {

float length, width, area;

printf("Enter the length & width of the rectangle::\\");

scanf("%f", &length);

scanf("%f", &width);

// It will calculate area of rectangle

area = length * width;

// It will print the final output

printf("\\Area of the rectangle is: %f units\\", area);

return 0;

}

Step-by-step explanation:

User Psarka
by
3.8k points