Computer Science, asked by camlin4994, 1 month ago

write a program in Q Basic to find the area and perimeter of a rectangle whose length is nothing

Answers

Answered by anindyaadhikari13
5

\textsf{\large{\underline{Correct Question}:}}

  • write a program in QBASIC to find the area and perimeter of a rectangle.

\textsf{\large{\underline{Solution}:}}

The given problem is solved using language - QBASIC.

CLS

INPUT "Enter the length of the rectangle: "; L

INPUT "Enter the breadth of the rectangle: "; B

P = 2 * (L + B)

A = L * B

PRINT "Perimeter:"; P; "unit."

PRINT "Area:"; A; "square unit."

END

\textsf{\large{\underline{Explanation}:}}

  1. Line 1: Clears the screen.
  2. Line 2-3: Accepts the length and breadth from the user.
  3. Line 4-5: Calculate the perimeter and area of the rectangle and store them in variables.
  4. Line 6-7: Display the perimeter and area of the rectangle.
  5. Line 8: End of program.

See the attachment for output.

Attachments:
Similar questions