Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ code Both images below are under the same number (1a and 1b) Please provide code for whole program and function only to both 1a

C++ code

Both images below are under the same number (1a and 1b)

image text in transcribed

image text in transcribedPlease provide code for whole program and function only to both 1a and 1b.

Implement a function void copyWord(char " destination, const char " source, int numChars); that copies characters from the C-string source into the array destination. The number of characters to be copied is stored in the parameter numChars . After copying the characters, your code should add a null terminator to destination, so that it can be used as a C-string. For example, if source contains the C-string "hi there" and numChars is 2, then the first three elements of destination will be 'h', 'i' and 'no'. Notice in the example we only copied 2 characters from source not 3. The third character, '10', is added by your code. RULES: No local variable allowed and no function calls allowed. Here is the driver used to test your code: Write a function with prototype int addDigits(char num[]) that returns the sum of the digits in a C-string num, which contains all digit characters, i.e. '0', '1', '2', '3', '4', '5', '6', '7', '8', or '9'. (If we just added num[0] + num[1] + nums[2] that would give the sum of ASCII values for '4', ' 3 ' and '6' which would be much bigger than 13 !) RULE: No function calls allowed. The main used to test your code looks like this: int main(){ char t[10] cint; cout

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