assignment-p-10.c (871B)
1 /* 2 * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 12 Dec 2025 3 * Repo: https://github.com/notamitgamer/bsc 4 * License: MIT 5 */ 6 7 /* Write a C program that defines a structure Rectangle with attributes length and width. 8 Include a user-defined function named calculateArea with the signature float 9 calculateArea(struct Rectangle r);. The function should calculate and return the area of 10 the rectangle. */ 11 12 #include <stdio.h> 13 14 struct Rectangle 15 { 16 float length; 17 float width; 18 }; 19 20 float calculateArea(struct Rectangle); 21 22 int main() 23 { 24 struct Rectangle rec; 25 printf("Enter the length of the Rectangle: "); 26 scanf("%f", &rec.length); 27 printf("Enter the width of the Rectangle: "); 28 scanf("%f", &rec.width); 29 printf("\nArea of the Rectangle = %g", calculateArea(rec)); 30 } 31 32 float calculateArea(struct Rectangle r) 33 { 34 return r.length * r.width; 35 }