Protec Computer Academy (An ISO 9001:2015 Certified Institute, Powered by E-Max Education, Branch Code EMAX/EK-80503, Registered by government of India.) is a best IT training center in Siwan with 100% Job placement assistance. Where you can learn Programming, WebDesigning, Hardware|Networking, Blogging, WordPress, Digitial marketing, English Speaking, And many more...| All certificates are valid in Government Jobs as well as in Private Companies. *** At Tara Market, Beside Vishal Mega Mart - Siwan*** +917541905230, Email- ahmad.irshad781@gmail.com *** Follow us on | | @welcome2protec

Sunday, June 21, 2020

Program to find area of a rectangle in C


C Program to find area of a rectangle:
By Ahmad Irshad | Programming Exercises and Solutions > 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.

Required knowledge for this exercise is


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

  1. /* C program to find area of a rectangle */
  2. #include <stdio.h> int main() { float length, width, area; /* * Input length and width of a rectangle */ printf("Enter length of a rectangle: "); scanf("%f", &length); printf("Enter width of a rectangle: "); scanf("%f", &width); /* farmula to Calculate area of rectangle */ area = length * width; /* Print area of rectangle */ printf("Area of rectangle = %.2f sq. units ", area); return 0;

Output:

  1. Enter length of a rectangle: 4
  1. Enter width of a rectagle: 15
  2. Area of rectangle = 60.00 sq. units





Next Topic to be updated soon..>>




Protec Computer Academy (An ISO 9001:2015 Certified Institute, Powered by E-Max Education, Branch Code EMAX/EK-80503, Registered by government of India.) is a best IT training center in Siwan with 100% Job placement assistance. Where you can learn Programming, WebDesigning, Hardware|Networking, Blogging, WordPress, Digitial marketing, English Speaking, And many more...| All certificates are valid in Government Jobs as well as in Private Companies. *** At Tara Market, Beside Vishal Mega Mart - Siwan*** +966532621401, Email- ahmad.irshad781@gmail.com *** Follow us on | | @welcome2protec

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

0 Comments:

Post a Comment

Please don't enter any spam link in the comment box.


Protec Computer Academy (An ISO 9001:2015 Certified Institute, Powered by E-Max Education, Branch Code EMAX/EK-80503, Registered by government of India.) is a best IT training center in Siwan with 100% Job placement assistance. Where you can learn Programming, WebDesigning, Hardware|Networking, Blogging, WordPress, Digitial marketing, English Speaking, And many more...| All certificates are valid in Government Jobs as well as in Private Companies. *** At Tara Market, Beside Vishal Mega Mart - Siwan*** +966532621401, Email- ahmad.irshad781@gmail.com *** Follow us on | | @welcome2protec
Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec
Contact Us