Questions: 5 831

Answers by our Experts: 5 728

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

ou are given a side of a square as input. Write a program to find the perimeter and area of the square.


Input

The input is an integer representing the length of the side of the square.


Output

The first line of the output should contain area of the square, and the second line of the output should contain the perimeter of the square as per the format shown in the sample output.


Explanation

Given the length of the side is 2.


As the area of square is side*side and the perimeter of the square is 4*side.


Then output should be

4

8

Sample Input 1

3

Sample Output 1

9

12

Sample Input 2

4

Sample Output 2

16

16


Write a program to print the sum of two numbers, A and B. If their sum is less than 10, otherwise print the product of numbers.


solution


Given

N number of days as input, write a program to convert N number of days to years (Y), weeks (W) and days (D).


solution


Write a program to print the sum of two numbers, A and B. If their sum is less than 10, otherwise print the product of numbers.


solution please



Diamond

Given an integer value 

N, write a program to print a number diamond of 2*N -1 rows as shown below.

Input

The first line of input is an integer 

N.

Explanation

In the given example, the number of rows in the diamond is 

5.

So, the output should be

. . . . 0 . . . . 
. . . 0 0 0 . . . 
. . 0 0 0 0 0 . . 
. 0 0 0 0 0 0 0 . 
0 0 0 0 0 0 0 0 0
. 0 0 0 0 0 0 0 . 
. . 0 0 0 0 0 . . 
. . . 0 0 0 . . . 
. . . . 0 . . . .




First Prime Number

You are given

N inputs. Write a program to print the first prime number in the given inputs.Input

The first line of input is an integer

N. The next N lines each contain an integer. Explanation

In the given example of

5 integers


W pattern with *

Write a program to print

W pattern of N lines using an asterisk(*) character as shown below.Note: There is a space after each asterisk * character.Input

The first line is an integer

N.Explanation

For

N = 5The output should be



* * * * * * * * * 
 * * * * * * * * 
  * * *   * * * 
   * *     * * 
    *       *



Solid Right Angled Triangle - 2

Given an integer number

N as input. Write a program to print the right-angled triangular pattern of N lines as shown below.Note: There is a space after each asterisk (*) character.Input

The first line of input is an integer

N.Explanation

In the given example, the solid right-angled triangle of side

5. Therefore, the output should be



      * 
    * * 
  * * * 
* * * *

Inverted Solid Right Triangle

Given an integer number

N as input. Write a program to print the right-angled triangular pattern of N lines as shown below.Note: There is a space after each asterisk (*) character.Input

The first line of input is an integer

N.Explanation

In the given example the solid right angled triangle of side

4. Therefore, the output should be


* * * * 

 * * * 

  * * 

   *


Hollow Right Triangle

Given an integer number

N as input. Write a program to print the hollow right-angled triangular pattern of N lines as shown below.Note: There is a space after each asterisk (*) character.Input

The first line of input is an integer

N.Explanation

In the given example the hollow right angled triangle of side

4. Therefore, the output should be 


* * * * 
  *   *
    * *
      *





LATEST TUTORIALS
APPROVED BY CLIENTS