You are on page 1of 1

IC 151 Computer Programming Lab

Autumn Semester 2023


Assignment 7

Q.1. Write a C++ program to implement a function that takes two inputs, a and n. The
function should return a series of numbers up to n, and all numbers are divisible by
a. Asks the user to enter a and n; a is for the division factor, and n is for the series
limit.

Q.2. Write a C++ program to implement a recursive function that prints the Fibonacci
series up to a specified length ‘n’ where the initial two numbers are 0 and 1, and
each subsequent number is the sum of the previous two numbers: 0 1 1 2 3 5 8
13…..

Q.3. Write a C++ program to implement a power function that takes two inputs, a
and n. The function should return the nth power of a. Asks the user to enter a and
n; a is for the base, and n is for power.

Q.4. Implement a C++ function that checks whether a number is prime or not.

Q.5. Write a function in C++ that takes two inputs, a and b. The function should
return the sum of all even and odd numbers between a and b. Asks the user to
enter a and b.

Q.6. Write a recursive function in C++ that finds and returns the Greatest Common
Divisor (GCD) of two given integers.

You might also like