Question
You are required to use the same menu driven program developed in the last class and now add the following two functions to it: Need
You are required to use the same menu driven program developed in the last class and now add the following two functions to it:
Need to write in C++
1. countTrailingZero(int m , int n) to count the trailing number of zeros in an integer m, after left shifting the number n times. Trailing zeros are the number of zeros you have in the binary conversion of the number on the right hand side before a 1 appears
Your answer should print out the result in decimal form.
int countTrailingZero(int, int)
Your output should be like this:
2. Write another function to calculate the occurrence of every character in the string. Both A and a are counted as one character.
To do: develop a menu showing both of these
(a) You should include at least 2 different test routines for each function.
(b) All the functions including main() should be implemented in one C file, not several C files.
(c) Must have the convertToBinary() so that the shifts can be validated.
Please answer both parts and include all functions. Program should be written in C++.
MAIN MEN U 1. Input a new string 2. Calculate the length of the string 3. Check the number of occurance of each character 4. Check the trailing zeros in a number 5. Exit program Enter a number 1234 Enter the numbers to shift left 5 The number is 00000000000000000000010011010010 The new number is : 00000000000000001001101001000000 The number of trailing zeros are 6 after shifting 5 timesStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started