You are on page 1of 3

Object Oriented Programming

Name: TE-53 Sec

LAB TASK 1

CLO 1,2 PLO 1

Q1. Write a C++ program to evaluate the following series up to n where n is entered by the user

x x x
ex 1 ...
2! 3! n!

user will also enter the value of x

Q2. What is the purpose of

a) function prototype

b) function call

c) function definition

d) return statement

Q3(a). Write a function isPrime(int n) that takes an integer type input parameter n and calculates and
returns 1 if the n is prime otherwise returns 0

1
Object Oriented Programming
Name: TE-53 Sec

Q3(b). Enhance the above function to print out total number of prime numbers up to n. For example
the total numbers of primes up to 100 is 25.

Q4. What is the difference between function definition and function prototype

Q5. Write a program that takes 2 inputs and determines the gcd (greatest common divisor) of the
two numbers

2
Object Oriented Programming
Name: TE-53 Sec

Q6. Write a C++ program to produce an n times multiplication table, where n is entered by the user.
For example, if n=4 the table should look like this

1 2 3 4
1 1 2 3 4
2 2 4 6 8
3 3 6 9 12
4 4 8 12 16

Q7. Write a program that calls a function which reverses the case of the user defined character. The
program should prompt the user to enter a character and pass it as an argument to the case function.
The function after reversing its case should return the resulting character to the main . By using
comments please mention where is the function prototype, function definition, function call

You might also like