dimanche 31 octobre 2021

Basic c++ programs. More specifically its my assignment [closed]

Problem 1: A country has Currency named TIKKA and Currency Notes of amount 750, 350, 200, 85, 15, 3 and 1 TIKKA’s. Write a C++ program which: • accepts amount in TIKKA’s as input (integer). • Pass the user entered TIKKAs to a function which displays total number of Currency Notes of TIKKA 750, 450, 350, 75, 18 and 1. For example: when user enter a number 1964, the results would be like this. Currency Note : Number 750 : 2 450 : 0 350 : 1 75 : 0 18 : 2 1 : 3

Problem 2: Write a C++ program that takes up to 10-digit integer input from user (can be 1 digit, 2 digit, and so on..); passes this to a function which reverses the digits. Finally, the reversed number should be displayed in the main function. For example: when user enters 10-digit like 1234567890 your function will reverse it to 987654321. Be careful for big integer values. [use functions, decision control]

Problem 3: Read about doing multiplication using Karatsuba method (https://en.wikipedia.org/wiki/Karatsuba_algorithm ). Write a C++ program which: • Prompts user to enter two large integer numbers (x, y). Both numbers must be more than 4 digits and less than 10 digits (do input validation, don’t use strings). The entered numbers could be negative or positive. For example: 820778 and -58712979 where x is 6-digit positive number and y is 8-digit negative number. • Make a function called Karatsuba() which takes these two integers and returns the multiplication result using Karatsuba algorithm. You might need to make another helper function called getDigits() which will get an integer as input and returns number of digits of that integer. getDigits() will help you find the value of m and Bm. • Display result in the main function.

Problem 4: The information about colours is to be stored in bits of a variable called colour. The bit number 0 to 7, each represent 8 colours of a rainbow, i.e. bit 1 represents Blue, 2 represents Green, and so on (see table below). Write a C++ program that asks the user to enter a number and based on this number, an eight lined rainbow (of asterisks *) is to be displayed, such that, if the bit is ON, respective colour is displayed otherwise black line is drawn (not visible).

Aucun commentaire:

Enregistrer un commentaire