Jane is solving aptitude questions as she is preparing for competitive exams. She came across a question where the dimensions of a rectangle were given, and the possible number of sub-rectangles that can be created within that rectangle (including itself) had to be found. She is now wondering if a generic solution can be found for this problem. Can you write a program to help her?
Read the input from STDIN and print the output to STDOUT.
Do not print arbitrary strings anywhere in the program, as these contribute to the standard output and test cases will fail.
Answers
across a question where the dimensions of a rectangle were given, and the possible number of sub-rectangles that can be created within that rectangle (including itself) had to be found. She is now wondering if a generic solution can be found for this problem. Can you write a program to help her?
Read the input from STDIN and print the output to STDOUT.
Do not print arbitrary strings anywhere in the program, as these contribute to the
Answer:
The program that give the possible number of sub-rectangles created with-in that rectangle, including that rectangle is as follows.
Explanation:
program : To count number of rectangles, in x grid.
Here, and will the length and breadth of main rectangle.
Program:
int rectCount(int , int )
{
return * * * ;
}
int main()
{
int , ;
cout rectCount;
return 0;
}
Check:
When, Input is given as :
The output :
That is,
There will be,
- rectangles of size x
- rectangles of size x
- rectangles of size x
- rectangle of size x .