Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Homework 2: Arrays and Functions Assigned Tuesday, February 13 The homework must be submitted to our teaching assistant (mfcekirdek94Ogmail.com) by Friday, February 23 anytime upto

image text in transcribed
image text in transcribed
Homework 2: Arrays and Functions Assigned Tuesday, February 13 The homework must be submitted to our teaching assistant (mfcekirdek94Ogmail.com) by Friday, February 23 anytime upto midnight (23.59). The subject of the email should say "BIL 214 Homework 2. Before submitting, place all your files in a directory called "YourFullName-HW2, tar and gzip your directory, and email a single file as attachment If you deviate from the submission instructions, you kee %5 of your grade. Part 1. In this program, you will simulate very large POSITIVE integers with arrays. Digits are stored in an array starting with the least significant at index 0. For example, an integer 123 is stored with 3 at index 0, 2 and index I and 1 at index 2. You may assume that the integers to be added or multiplied has at most 20 digits. Write the following functions: int add(int x, int sizex, int yl, int sizey, int resI), which takes two arrays x and y and their respective sizes, performs addition and stores the result into the array res. Return the number of digits of the resulting sum ie. number of digits stored into res). int multiply (int x, int sizex, int yl, int sizey, int res]), which takes two arrays x and y and their respective sizes, performs multiplication and stores the result into the array res. Return the number of digits of the resulting product (i.e. number of digits stored into res). int divide(int xD. int sizex, int y0. int sizey, int res), which takes two arrays x and y and their respective sizes, performs integer division of x by y, and stores the result into the array res. Return the number of digits of the result int mod(int x, int sizex, int y. int sizey, int res]), which takes two arrays x and y and their respective sizes, performs of x mod y, and stores the result into the array res. Return the number of digits of the result. printNumber(int x, int sizex), which prints the integer represented by array x mod operations. . a main) function that creates some numbers and tests the add, multiply, division and Part 2. Imagine a mouse that walks within a 50 by 50 array. The mouse holds a pen in one of two positions: up or down. While the pen is up, the mouse does not write anything. While the pen is down, the mouse marks each array location it passes by. You will read a sequence of commands (one per line) from standard input (I suggest using an input textfile and use input redirection as you did in Lab 4) and walk the mouse. The mouse always starts at location (0,0) with its pen up. Possible commands are: Pen up e 2 Pen down 3 Turn right 4 Turn left Homework 2: Arrays and Functions Assigned Tuesday, February 13 The homework must be submitted to our teaching assistant (mfcekirdek94Ogmail.com) by Friday, February 23 anytime upto midnight (23.59). The subject of the email should say "BIL 214 Homework 2. Before submitting, place all your files in a directory called "YourFullName-HW2, tar and gzip your directory, and email a single file as attachment If you deviate from the submission instructions, you kee %5 of your grade. Part 1. In this program, you will simulate very large POSITIVE integers with arrays. Digits are stored in an array starting with the least significant at index 0. For example, an integer 123 is stored with 3 at index 0, 2 and index I and 1 at index 2. You may assume that the integers to be added or multiplied has at most 20 digits. Write the following functions: int add(int x, int sizex, int yl, int sizey, int resI), which takes two arrays x and y and their respective sizes, performs addition and stores the result into the array res. Return the number of digits of the resulting sum ie. number of digits stored into res). int multiply (int x, int sizex, int yl, int sizey, int res]), which takes two arrays x and y and their respective sizes, performs multiplication and stores the result into the array res. Return the number of digits of the resulting product (i.e. number of digits stored into res). int divide(int xD. int sizex, int y0. int sizey, int res), which takes two arrays x and y and their respective sizes, performs integer division of x by y, and stores the result into the array res. Return the number of digits of the result int mod(int x, int sizex, int y. int sizey, int res]), which takes two arrays x and y and their respective sizes, performs of x mod y, and stores the result into the array res. Return the number of digits of the result. printNumber(int x, int sizex), which prints the integer represented by array x mod operations. . a main) function that creates some numbers and tests the add, multiply, division and Part 2. Imagine a mouse that walks within a 50 by 50 array. The mouse holds a pen in one of two positions: up or down. While the pen is up, the mouse does not write anything. While the pen is down, the mouse marks each array location it passes by. You will read a sequence of commands (one per line) from standard input (I suggest using an input textfile and use input redirection as you did in Lab 4) and walk the mouse. The mouse always starts at location (0,0) with its pen up. Possible commands are: Pen up e 2 Pen down 3 Turn right 4 Turn left

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

Database Basics Computer EngineeringInformation Warehouse Basics From Science

Authors: Odiljon Jakbarov ,Anvarkhan Majidov

1st Edition

620675183X, 978-6206751830

More Books

Students also viewed these Databases questions

Question

1. Are my sources credible?

Answered: 1 week ago

Question

3. Are my sources accurate?

Answered: 1 week ago

Question

1. Is it a topic you are interested in and know something about?

Answered: 1 week ago