*Question 1: **(**8 marks)*

Write a program to print the pattern below. Taking n as input, print n lines that print the pattern.

Sample input 1: 3 Sample output 1: * * ** ** ****** Sample input 2: 5 Sample output 2: * * ** ** *** *** **** **** **********

*Question 2: **(12 marks)*

The int* *datatype has a limitation of maximum value. It can only store values upto a certain limit. So what we want to do is take a very big integer and add 1 to it.

INPUT FORMAT:

First line contains number of digits in the integer, n. This is at maximum 50.

The next line consists of all the digits of the integer, separated by spaces.

You are required to add 1 to this integer and output the digits of the resulting integer (without spaces)

Sample input: 12 8 7 5 1 2 5 4 8 7 5 4 5 Sample output: 875125487546

*Question 3: **(**8 marks)*

Leap years are an interesting way of putting together lost time over the previous 4 years. These are those years when February has 29 days. One of your friends Raj was born on 29th of February. He wishes to know how many times till date he lived through his actual birthday (29th February). Take his birth year and present year as inputs and print the number of times he has experienced 29th of February. Note if present year is a leap year, do include its 29th of February as well. You may also display an error as “Birth Year is incorrect” if the birth year entered is not a leap year.

Note: Leap years are years which are multiples of 4 with the exception of years which are divisble by 100 but not by 400.

Sample input 1: 1996 2019 Sample output 1: 6 Sample input 2: 1997 2019 Sample output 2: Birth year is incorrect

*Question 4: **(12** marks)*

Sort an array in ascending order by flipping (exchanging) 2 adjacent integers not in the correct order until there is no such pair.

The leftmost swappable pair must be swapped first, i.e. the first pair encountered while going from left to right, which is in the opposite (descending order) should be swapped. Then the whole process should be repeated.

INPUT FORMAT:

First line contains 1 integer N denoting the number of integers in input. Next line contains N integers separated by spaces.

OUTPUT FORMAT:

For each flip performed, display the array in a line separated by spaces.

Sample input: 5 10 7 6 2 5 Sample output 10 7 6 2 5 7 10 6 2 5 7 6 10 2 5 6 7 10 2 5 6 7 2 10 5 6 2 7 10 5 2 6 7 10 5 2 6 7 5 10 2 6 5 7 10 2 5 6 7 10

*Question 5: **(12** marks)*

In this question we’ll deal with Fibonacci series. The series is defined on whole numbers like fib(0), fib(1),… as follows:

fib(0) = 0

fib(1) = 1

fib(n) = fib(n-1) + fib(n-2), for n >= 2

INPUT FORMAT:

An integer N, 0 <= N <= 1000

OUTPUT FORMAT:

Add the unit digits of all the Fibonacci numbers from fib(0) to fib(N) and print only this sum

Sample Input: 8 Sample Output: 24

*Question 6: **(8** marks)*

You are to write a program which takes 2 complex numbers as input and prints the sum and multiplication of the 2 complex numbers.

INPUT FORMAT:

The first and second lines contain 2 integers (the real and imaginary parts) for each complex number involved.

OUTPUT FORMAT:

The complex numbers sum and product on separate lines in the form a+bi or a-bi (depending on whether the complex part is negative or not).

Sample input: 1 2 1 3 Sample output: 2+5i -5+5i

3rd Code