1.

Write a program to find the last prime number before a specified number that has to input by user.

A sample output is shown below:
 

Enter number to find last prime number occurs before it: 21

19 is the last prime number before entered number

2.

Write a program to find the two largest values among the 10 numbers. You must input each number only once.

A sample output is shown below:
 

Enter the first number: 20

Enter next number: 30

Enter next number: 12

Enter next number: 52

Enter next number: 56

Enter next number: 21

Enter next number: 45

Enter next number: 10

Enter next number: 56

Enter next number: 89

 

Largest is 89

Second largest is 56

3.

Write a function multiple that determines for a pair of integers whether the second integer is a multiple of the first. The function should take two integer arguments and return true if the second is a multiple of the first, false otherwise. Use this function in a program that inputs a series of pairs of integers.

Example :
Input : 23 56
Output : false

4.

Write a program that asks for a number and a power. Write a recursive function that takes the number to the power. Thus, if the number is 2 and the power is 4, the function will return 16.

A sample output is shown below:

Enter a number: 2.5

To what power? 2

2.5 to the 2th power is 6.25

5.

A palindrome is a number or a text phrase that reads the same backwards as forwards. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554 and 11611. Write a program that reads in a five-digit integer and determines whether it is a palindrome. (Hint: Use the division and modulus operators to separate the number into its individual digits.)

A sample output is shown below:
 

Enter a five-digit number: 11611

11611 is a palindrome