Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. What is the maximum number of characters you can input? 2. What happens when

ID: 3705684 • Letter: 1

Question

1. What is the maximum number of characters you can input?
2. What happens when you enter more than this number?
3. What is passed to the *getnchar() function?
4. What is returned from the *getnchar() function?
5. What happens when you press ctrl-d before any input? Why? (Which line of code effects this?)
6. What change would you need to make to allow the user to enter up to 50 characters into input[].
7. Aside from pressing ctrl-d at the beginning of a line, is there any way to enter less than 9 characters?

Explanation / Answer

If you post more tha 4 parts in a question, as per chegg guidelines I have to solve only first 4 parts.

Ques 1. We can enter a maximum of 9 characters as the length of char array is 10, but the last position is saved for the termination character . So, we can enter upto 9 characters.

Ques 2. If we enter more than 9 characters, the program will save only the first 9 characters into the char array input.

Ques 3. The char array input and the last index (LEN - 1) is to be passed.

Ques 4. The string str is modified and the string str is now reduced to n - 1 characters and the rest of the remoaining characters are returned as a string.

Ques 6. To allow the user to enter up to 50 characters into input[], we need to change the length of input array. So, we need to change the value of LEN to 51.