FUNDAMENTALS OF COMPUTER

COMPUTER PROGRAMMING FUNDAMENTALS

WHAT IS PROGRAMMING

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
A function named ‘area’ calculates area of a rectangle. Which of the following is its function call statement in main program?
A
area ____ rect=area (length, breadth)
B
area=length × breadth
C
print(area ____ rect)
D
A and C
Explanation: 

Detailed explanation-1: -Area of a rectangle = length × width . Length = 5 + 2 = 7 cm.

Detailed explanation-2: -To find the area of a rectangle, multiply the length by the width. The formula is: A = L * W where A is the area, L is the length, W is the width, and * means multiply.

Detailed explanation-3: -The ‘getArea’ method calculates and returns the area of the rectangle by multiplying the length and width attributes. An object of class ‘Area’ is created and the ‘setDim’ method is called to set the length and width. Finally, the ‘getArea’ method is called to print the area of the rectangle.

There is 1 question to complete.