09 Function
09 Function
(Total 27 questions)
5. Function that takes two numbers as input and determines if the first number is greater than, *
equal to or less than the second number.
7. Function to calculate the sum of n numbers coming from the console and stored in an array. *
8. Function that takes an array of n integer numbers as input and prints them in reverse order. *
10. Function to take two positive numbers x and y as input and calculate x to the power y. *
15. Function that finds and returns the minimum value in an array. **
16. Function that multiplies the array elements by 2 and returns the array. *
Sample input Sample output
157 -28 -37 26 10 314 -56 -74 52 20
12 45 1 10 5 3 22 24 90 2 20 10 6 44
19. Function “GeneratePrime()” to compute the prime numbers less than N, where N is an input ***
integer. GeneratePrime() uses IsPrime() to check whether a number is prime or not.
20. Function “GenNthPrime()” to compute the Nth prime number, where N is an integer input. ***
Formula:
22. Function find_substr( ) that takes two string arrays (a, b) as parameters, returns 1 if string b **
is found anywhere in string a, or returns –1 if no match is found.
(Assuming, strlen(a)>strlen(b))
23. Function find_substr( ) that takes two string arrays (a, b) as parameters, uses function ***
str_length() to determine the lengths of the strings, and then looks for the smaller string
anywhere in the bigger string. It returns 1 if the substring is found, or returns –1 if no match
is found.
25. Program that implements function to perform operations on a 3X5 matrix: ***
InputMatrix()
ShowMatrix()
ScalarMultiply()
InputMatrix()
ShowMatrix()
ScalarMultiply()
3 5 Original:
7 16 55 13 12
7 16 55 13 12 12 10 52 0 7
12 10 52 0 7 -2 1 2 4 9
-2 1 2 4 9
Multiplied by -1:
-1 -14 -32 -110 -26 -24
-24 -20 -104 0 -14
4 -2 -4 -8 -18
27. Program to convert a positive integer to another base using the following functions- ****