Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab #8 EGRE245 Spring 2018 1. Write a C program that inputs and then adds together two up to 100 digit numbers each which

image text in transcribed
" Lab #8 EGRE245 Spring 2018 1. Write a C program that inputs and then adds together two up to 100 digit numbers each which contain the same number of digits. For example 3 14 macbook-/cprogs/ a.out : Value#1: 1234 Value 2: 4567 Resulti 5881 macbook:~/eprogs/s a.out Value #1 :1234 va tue#2: 1234567 Error - numbers must be the sane length t macbook:-/cprogs/h a. out Value 1: 99999999999999999999999999999999999999999999999999 value#2: 1eeeeeeeeeeeeeeeeeeeeeeeeeeee00000000 eeee eaeee0e0eeeaeeee8 macbooki /cprogs/ Store your numbers in integer arrays one digit per cell. Use getchar O for your input (i.e. read in a single digit at a time storing each one in your array until you get to the newline character; cf. pages 255, 256 in the notes). Once you have inputted your numbers into arrays you then iterate through the operand arrays adding corresponding cells in each array (making sure to consider if there has been a carry from the previous place) storing the result in a new array. Then print out the result. 2. How would you modify your program to handle operands of different lengths? " Lab #8 EGRE245 Spring 2018 1. Write a C program that inputs and then adds together two up to 100 digit numbers each which contain the same number of digits. For example 3 14 macbook-/cprogs/ a.out : Value#1: 1234 Value 2: 4567 Resulti 5881 macbook:~/eprogs/s a.out Value #1 :1234 va tue#2: 1234567 Error - numbers must be the sane length t macbook:-/cprogs/h a. out Value 1: 99999999999999999999999999999999999999999999999999 value#2: 1eeeeeeeeeeeeeeeeeeeeeeeeeeee00000000 eeee eaeee0e0eeeaeeee8 macbooki /cprogs/ Store your numbers in integer arrays one digit per cell. Use getchar O for your input (i.e. read in a single digit at a time storing each one in your array until you get to the newline character; cf. pages 255, 256 in the notes). Once you have inputted your numbers into arrays you then iterate through the operand arrays adding corresponding cells in each array (making sure to consider if there has been a carry from the previous place) storing the result in a new array. Then print out the result. 2. How would you modify your program to handle operands of different lengths

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions