Sunday, June 21, 2020
Program to find area of a rectangle in C
C Program to find area of a rectangle:
Write a C program to find area of a rectangle by taking input length and width from user. Let's see the logic to find area of rectangle whose length and width are already given.
Before writing any program you just imagine about output screen first. For example: what input to be given, and output to be displayed. Let's have a look at the below example:
INPUT:
Enter length of a rectangle: 4
Enter width of a rectangle: 15
OUTPUT:
Area of a rectangle = 60.00 sq. units
Logic to find area of a rectangle:
1) Print a massage to the user like "Enter length and width of a rectangle:" using printf();
2) Input length and width using scanf(); and store it in two different variables length and width.
3) Now calculate area of a rectangle using farmula: Area = length * width
4) At last print the result of area of a rectangle. that's it!
Program to find area of a rectangle:
Output:
Help others by sharing this page.
Ahmad Irshad
Author & Editor
I love blogging, teaching, learning computer science and sharing it to others. I've written and develped this site so that students may learn computer science related tutorials eaisly. MCA / MCITP
Sunday, June 21, 2020
C
Subscribe to:
Post Comments (Atom)
0 Comments:
Post a Comment
Please don't enter any spam link in the comment box.