Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

2. Write another function to calculate the occurrence of every character in the string. Both A and a are counted as one character.

image text in transcribed

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 times

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Business Process Driven Database Design With Oracle PL SQL

Authors: Rajeev Kaula

1st Edition

1795532386, 978-1795532389

More Books

Students also viewed these Databases questions

Question

=+ (a) Show that D is finitely but not countably additive on 9.

Answered: 1 week ago

Question

1. Describe the power of nonverbal communication

Answered: 1 week ago