x1: Write a program that uses a void function – a function that does not return a value. Call this function “isVowel()”. Take a character input from user, inmain()function, and pass the value to theisVowel()function.isVowel()function checks if the character is a vowel or not and updates themain()function using a “by Reference” parameter, not by returning a value. Print whether the character entered by the user is a vowel or not, in themain()function.
Ex2: Write a program that uses a function,reverseDigit, that takes an integer as a parameter and returns the number with its digits reversed. For example, the value ofreverseDigit(12345)is54321; the value ofreverseDigit(5600)is65; the value ofreverseDigit(7008)is8007.
Ex3: Modify the program you wrote in Ex2 by making the return type ofreverseDigitfunctionvoidfor the same output. Do not print the result inside thereverseDigitfunction. The functionreverseDigitcan no longer return a value. You will need to use a “by Reference” parameter to update the main function accordingly.
Hint:This is how you can separate digits from an integer: If the number is 2345, you can use the % operator to separate the right most digit by 2345 % 10 which will give you 5. Then divide the num by 10 (decimal) and you will be left with 234. Repeat.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here