You are on page 1of 2

Lab Tasks (Functions)

Task 1
Write a function that calculates and print the sum of given numbers

int Sum (int num1, int num2)

int Sum (int num1, int num2, int num3)

int Sum (int num1, int num2, int num3, int num4)

Overload functions with different signatures.

Task 2
Write a Function that computes the power of given number.

int Power(int Base, int Exponent )

Task 3
Write a program that calculates and prints the product of the odd integers between the range

int OddProduct (int initial, int ending)

Task 4
Write a function that takes a number as argument and return 1 if number is prime otherwise
return 0.

int isPrime(int number)

Task 5
Write a function which take 2 values as range and print all prime number between the range
given. For this you may use your own function isPrime().

Void PrintAllPrime(int first, int last )

Task 6
Create an array of user defined size. Fill this array with random numbers (Auto Generated). Create a
menu from 1 to 6 to perform operation on array. As the option is selected. It repeats until the user press
8 for exit. For each option you must write a function which takes the array and any other required data.
1. Update array (Ask user to enter index and value to update)
2. Print the array
3. Find minimum
4. Find maximum
5. Search a number (Ask the user enter a number to search, and return the index of number
searched)
6. Sort the array

7. Print the array in reverse order


8. Exit.

You might also like