Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Questions

Q1PROBLEM

LESSON ON SQUARE

Lesson on Square
 
ExSeed books are very popular for school kids. ExSeed has now come out with an
innovative idea of giving dynamic online practice quizzes.
 

 
Write a program to solve one of their mathematical problems?

Given the coordinates of the center of the square (x,y) and the side of the square,
find the coordinates of the 4 vertices of the square.
Assume that the side of the square is always even.
 
Input Format:
Input consists of 3 integers.
The 1st integer corresponds to the x-coordinate of the centre of the square.
The 2nd integer corresponds to the y-coordinate of the centre of the square.
The 3rd integer corresponds to the side of the square.
 
 
Output Format:
Output consists of 8 integers.
The first 2 integers correspond to the x and y coordinates the upper right corner of
the square.
The next 2 integers correspond to the x and y coordinates the lower right corner of
the square.
The next 2 integers correspond to the x and y coordinates the lower left corner of the
square.
The next 2 integers correspond to the x and y coordinates the upper left corner of the
square.
The x and y coordinates of each vertex should be printed on a separate line,
separated by a ,(comma).
Refer sample input and output for formatting specifications.
 
 
Sample Input:
7
6
4
Sample Output:
9,8
9,4
5,4
5,8
Q2PROBLEM

LESSON ON RECTANGLE

Lesson on Rectangle
 

ExSeed books are very popular for school kids. ExSeed has now come out with an
innovative idea of giving dynamic online practice quizzes.

Can you help them in solving one of their mathematical problems?

Given the coordinates of the lower left corner of the rectangle (x,y) and the length
and breadth of the rectangle, find the coordinates of the 4 vertices of the rectangle.

Assume that the length and breadth of the rectangle is always even. 

Input and Output Format:


 

Input consists of 4 integers.

The 1st integer corresponds to the x-coordinate of the lower left corner of the
rectangle.
The 2nd integer corresponds to the y-coordinate of the lower left corner of the
rectangle.
The 3rd integer corresponds to the length of the rectangle.
The 4th integer corresponds to the breadth of the rectangle.
 

Output consists of 8 integers.

The first 2 integers correspond to the x and y coordinates the lower left corner of the
rectangle

The next 2 integers correspond to the x and y coordinates the upper left corner of the
rectangle.
The next 2 integers correspond to the x and y coordinates the upper right corner of
the rectangle.

The next 2 integers correspond to the x and y coordinates the lower right corner of
the rectangle.

The x and y coordinates of each vertex should be printed on a separate line,


separated by a , (comma).

Refer sample input and output for formatting specifications.

Sample Input:
7

Sample Output:
7,6

7,10

9,10

9,6
Answers
A1 ANSWER

#!/bin/bash

read x

read y

read L

l=`expr $L / 2`

a=`expr $x + $l`

b=`expr $x - $l`

c=`expr $y + $l`

d=`expr $y - $l`

echo $a,$c

echo $a,$d

echo $b,$d

echo $b,$c

A2 ANSWER

#!/bin/bash

read x

read y

read l

read b

ny=`expr $y + $l`

nx=`expr $x + $b`
echo $x,$y

echo $x,$ny

echo $nx,$ny

echo $nx,$y

You might also like