Function
Function
1. Write a complete c++ Program to input a character, send the character to the function and if
the character is vowel (‘a’,’e’,’i’, ‘o’,’u’, ‘y’) return true otherwise return false. (Using this
function prototype): bool isVowel(char x).
2. Write a program to declare two integer variable, input the values from the keyboard and
send them to the function to return their sum:
(using this function prototype): int getSum(int a, int b);
3. Write a program to input two integers values, send them to a function and return the larger
value. (using this function prototype): int larger(int x, int y);
4. Write a program to prompt the user to input a character and send it to the function to return
true if the letter is small otherwise return false (using this function prototype): bool
isSmall(char letter);
5. Write a program to prompt the user to input four integer variables namely x1,x2,y1,y2. And
send them to a function to calculate the distance using the following formula: √((x2-x1)^2)+
(y2-y1)^2 )
(using this function prototype): double getDistance(int x1, int x2, int y1, int y2);
6. Write c++ program that ask the user to enter five marks of a student and save then into
array, then calculate the average of these marks using function.
7. Write a c++ program that ask the user to enter element of an array of size 5 then print them
using a function.
8. Write a program to convert the time from 24-hour notation to 12-hour notation and vice
versa. Your program must be menu driven, giving the user the choice of converting the time
between the two notations. Furthermore, your program must contain at least the following
function: a function to convert the time from 24-hour notation to 12-hour notation, a
function to convert the time from 12-hour notation to 24-hour notation, a function to display
the choices, function(s) to get the input, and function(s) to display the results. (For 12-hour
time notation, your program must display AM or PM.)
The formula for calculating the amount to be paid is as follows: For the first 40 hours, the
rate is the given rate; for hours over 40, the rate is 1.5 times the given rate.
d. Write the definition of the function printCheck that prints the hours worked, rate per hour,
and the salary.
e. Write the definition of the function funcOne that prompts the user to input a number. The
function then changes the value of x by assigning the value of the expression 2 times the
(old) value of x plus the value of y minus the value entered by the user.
f. Write the definition of the function nextChar that sets the value of z to the next character
stored in z.
g. Write the definition of a function main that tests each of these functions.