Write a script to add two 20-digit numbers and print the result. This is not as easy as it might sound at first, because integer types may not be able to store a value this large. One way to handle large integers is to store them in vectors, where each element in the vector stores a digit of the integer. Your script should initialize two 20-digit integers, storing each in a vector, and then add these integers, also storing the result in a vector. Create the original numbers using the randi function. Hint: add 2 numbers on paper first, and pay attention to what you do! For example, by running the code, you will see this in the command window: 4 6 Or 9 6 67 3 5 5 1 9 7 7 1 3 5 4 0 1 1 9 4 3 8 7 0 9 1 8 4 5 6 7 9 9 6 290 5 6 4 8 7 3 4 3 7 7 4 2 8 0 8 065 2 5 1 6 4 3 5 20 4 1 3884 3 6 9 0949 706 9 5 3 8 4 9 0 1 7 2 7 6 5 2 5 7 1 3 1 3 082 3 6 4 1 1 0 4 8 8 1 9 7 3 3 6 5 85

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Matlab Question

Write a script to add two 20-digit numbers and print the result. This is not as easy as it might sound at first,
because integer types may not be able to store a value this large. One way to handle large integers is to
store them in vectors, where each element in the vector stores a digit of the integer. Your script should
initialize two 20-digit integers, storing each in a vector, and then add these integers, also storing the result
in a vector. Create the original numbers using the randi function. Hint: add 2 numbers on paper first, and
pay attention to what you do! For example, by running the code, you will see this in the command window:
+
Or
+
6 48 7 3 4 3 7 7 4
7 7 13 5402808065 2 5
1
6
49 6 6 7 35 5
6 9
LO
4
3
1 1 9 4 3 8 7 0 9 1 8 4 5 6 7 9 9 6 290
LO
1 5
3 5 204 1 0949 706765 2 7 2
88 4 3 6 995 3 8490 5 7 1 3 1 3
0 8 2 3 6 4 1 1 0 4 8 8 1 9 7 3 3 6 5 85
Transcribed Image Text:Write a script to add two 20-digit numbers and print the result. This is not as easy as it might sound at first, because integer types may not be able to store a value this large. One way to handle large integers is to store them in vectors, where each element in the vector stores a digit of the integer. Your script should initialize two 20-digit integers, storing each in a vector, and then add these integers, also storing the result in a vector. Create the original numbers using the randi function. Hint: add 2 numbers on paper first, and pay attention to what you do! For example, by running the code, you will see this in the command window: + Or + 6 48 7 3 4 3 7 7 4 7 7 13 5402808065 2 5 1 6 49 6 6 7 35 5 6 9 LO 4 3 1 1 9 4 3 8 7 0 9 1 8 4 5 6 7 9 9 6 290 LO 1 5 3 5 204 1 0949 706765 2 7 2 88 4 3 6 995 3 8490 5 7 1 3 1 3 0 8 2 3 6 4 1 1 0 4 8 8 1 9 7 3 3 6 5 85
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Array
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education