Assignment 2b. Programming Fundamentals

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Assignment 2(b) Programming Fundamentals

1. Write a program that asks the user for a number n and gives
him the possibility to choose between computing the sum
and computing the product of 1,...,n.

2. Write a program to print first 20 terms of the series 3n+2 which


are not multiples of 4.

3. Given a binary number convert it into decimal.

4. Given a decimal convert it into binary.

5. Write a program to find square root of an input.

a. Just find the integral part


b. Find the square root with an accuracy of n decimal
points, n is provided by the user.

6. You are given S a sequence of n integers S = s1, s2, ..., sn.


Please, compute if it is possible to split S into two parts : s1, s2,
..., si and si+1, si+2, .., sn
(1 <= i < n) in such a way that the first part is strictly decreasing
while the second is strictly increasing one. First take n as input
and then take n more integers, output yes or no.

You might also like