C Online Compiler
Example: C Program to Find Area of Rectangle using Structure
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// C Program to Find Area of Rectangle using Structure #include <stdio.h> struct Rectangle { float length; float width; float area; }; int main() { // It will declare `Rect` of type `Rectangle` struct Rectangle Rect; printf("Enter the length & width of the rectangle::\n"); scanf("%f", &Rect.length); scanf("%f", &Rect.width); // It will calculate area of rectangle Rect.area = Rect.length * Rect.width; // It will print the final output printf("\nArea of the rectangle is: %f units\n", Rect.area); return 0; }
45 90
Output
Clear
ADVERTISEMENTS