Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

Question

Please code using C++ and only use the header <iostream>. The use of any additional headers will not be accepted. Thank you!

Transcribed Image Text:**Task 13: bigNumber.cpp** **Objective:** Write functions for performing arithmetic on 100-digit integers. These functions should handle input, output, and addition operations. **Requirements:** - The input function should be silent and not produce any output. - The addition function should not involve any input or output operations. - Functions should not assume any specifics about other functions or the main program structure. - The number of digits should be defined as a global constant. **Function Prototypes:** ```cpp void readBig(int[]) void addBig(int[], int[], int[]) void printBig(int[]) ``` Use the provided main program to test these functions.
[画像:```cpp #include <iostream> using namespace std; // This program will test three functions capable of reading, adding, // and printing 100-digit numbers. // Do not change these function prototypes: void readBig(int[]); void printBig(int[]); void addBig(int[], int[], int[]); // This constant should be 100 when the program is finished. const int MAX_DIGITS = 100; // There should be no changes made to the main program when you turn it in. int main() { // Declare the three numbers, the first, second and the sum: int num1[MAX_DIGITS], num2[MAX_DIGITS], sum[MAX_DIGITS]; bool done = false; char response; while (not done) { cout << "Please enter a number up to " << MAX_DIGITS << " digits: "; readBig(num1); cout << "Please enter a number up to " << MAX_DIGITS << " digits: "; readBig(num2); addBig(num1, num2, sum); printBig(num1); cout << "\n+\n"; printBig(num2); cout << "\n=\n"; printBig(sum); cout << "\n"; cout << "test again?"; cin >> response; cin.ignore(900, '\n'); done = toupper(response) != 'Y'; } return 0; } ``` **Explanation:** This code snippet is written in C++ and is designed to handle 100-digit arithmetic operations. It includes the following main components: 1. **Function Prototypes:** - `void readBig(int[]);` – To read a big integer. - `void printBig(int[]);` – To print a big integer. - `void addBig(int[], int[], int[]);` – To add two big integers. 2. **Constant Declaration:** - `const int MAX_DIGITS = 100;` – Specifies the maximum number of digits for the big integers. 3. **Main Function:** - Declares three arrays (`num1`, `num2`, `sum`) with a size of `MAX_DIGITS` to store two big integers and their sum. - Uses a boolean flag `done` to control the loop. - Inputs two numbers with at most 100 digits, adds them, and prints the result. - Re]
expand button
Transcribed Image Text:```cpp #include <iostream> using namespace std; // This program will test three functions capable of reading, adding, // and printing 100-digit numbers. // Do not change these function prototypes: void readBig(int[]); void printBig(int[]); void addBig(int[], int[], int[]); // This constant should be 100 when the program is finished. const int MAX_DIGITS = 100; // There should be no changes made to the main program when you turn it in. int main() { // Declare the three numbers, the first, second and the sum: int num1[MAX_DIGITS], num2[MAX_DIGITS], sum[MAX_DIGITS]; bool done = false; char response; while (not done) { cout << "Please enter a number up to " << MAX_DIGITS << " digits: "; readBig(num1); cout << "Please enter a number up to " << MAX_DIGITS << " digits: "; readBig(num2); addBig(num1, num2, sum); printBig(num1); cout << "\n+\n"; printBig(num2); cout << "\n=\n"; printBig(sum); cout << "\n"; cout << "test again?"; cin >> response; cin.ignore(900, '\n'); done = toupper(response) != 'Y'; } return 0; } ``` **Explanation:** This code snippet is written in C++ and is designed to handle 100-digit arithmetic operations. It includes the following main components: 1. **Function Prototypes:** - `void readBig(int[]);` – To read a big integer. - `void printBig(int[]);` – To print a big integer. - `void addBig(int[], int[], int[]);` – To add two big integers. 2. **Constant Declaration:** - `const int MAX_DIGITS = 100;` – Specifies the maximum number of digits for the big integers. 3. **Main Function:** - Declares three arrays (`num1`, `num2`, `sum`) with a size of `MAX_DIGITS` to store two big integers and their sum. - Uses a boolean flag `done` to control the loop. - Inputs two numbers with at most 100 digits, adds them, and prints the result. - Re
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
    Recommended textbooks for you
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education