Short Answer Questions (3-4 sentences expected per question) 1) Give a brief description of the three different loop types (for, while, do-while). When is each loop type most useful? Are there certain problems that can only be solved with one type of loop? 2) When we pass an integer into a function as an argument, the value gets copied into the parameter. When we pass an array of integers into a function, does every array element also get copied? Why or why not? 3) There are several reasons we might choose to write a user-function in our program, instead of just using a the main() function. Give two benefits of writing our own functions and explain each in a sentence or two.
Short Answer Questions (3-4 sentences expected per question) 1) Give a brief description of the three different loop types (for, while, do-while). When is each loop type most useful? Are there certain problems that can only be solved with one type of loop? 2) When we pass an integer into a function as an argument, the value gets copied into the parameter. When we pass an array of integers into a function, does every array element also get copied? Why or why not? 3) There are several reasons we might choose to write a user-function in our program, instead of just using a the main() function. Give two benefits of writing our own functions and explain each in a sentence or two.
Short Answer Questions (3-4 sentences expected per question) 1) Give a brief description of the three different loop types (for, while, do-while). When is each loop type most useful? Are there certain problems that can only be solved with one type of loop? 2) When we pass an integer into a function as an argument, the value gets copied into the parameter. When we pass an array of integers into a function, does every array element also get copied? Why or why not? 3) There are several reasons we might choose to write a user-function in our program, instead of just using a the main() function. Give two benefits of writing our own functions and explain each in a sentence or two.
Short Answer Questions (3-4 sentences expected per question) 1) Give a brief description of the three different loop types (for, while, do-while). When is each loop type most useful? Are there certain problems that can only be solved with one type of loop? 2) When we pass an integer into a function as an argument, the value gets copied into the parameter. When we pass an array of integers into a function, does every array element also get copied? Why or why not? 3) There are several reasons we might choose to write a user-function in our program, instead of just using a the main() function. Give two benefits of writing our own functions and explain each in a sentence or two. 4) In C, we have a special character (NULL character, ‘\0’) for indicating the end of a string. Would it make sense to have a similar special integer value to indicate the end of integer arrays? Why or why not?
Transcribed Image Text:1) int median_of_three (int a, int b, int c)
This function accepts three integers as input and returns the median (middle value) of
the three. Several examples are given below, along with the expected return value.
Input numbers
2, 3,
Expected return value
1
2, 4, 3
3
5, 5, 5
5
1, 1, 5
1
2) void print_reverse (char str[])
This function will accept a string as an input argument and return nothing. All this
function does is print the string in reverse order. For this question, you may include
string.h and use strlen(), but you may NOT use the string function strrev().
Several examples are given below.
Input string
Expected printout
"H"
"H"
"Hello"
"olleH"
"Hello, World!"
"racecar"
"!dlrow ,olleH"
“racecar"
When attempting this question, remember that a string is nothing more than an array of
characters with the NULL character (\0') as a terminator.
3) int is_ascending (int arr[], int len)
This function will accept an array of integers as input, as well as the length of that array.
It will return an integer. If the elements of the array are in strict ascending order, it will
return the integer 1, and 0 otherwise. Several examples are given below indicating how
your function should behave.
Expected return value
Input array
{-5, 10, 99, 1234}
{2, 3, 3, 4, 5}
{-99}
{4, 6, 7, 3, 7, 9}
{1, 1, 1, 1}
1
(values 3 and 3 are equal, not ascending)
1
(an array with one value is ascending)
How you accomplish this is completely up to you. You'll need a loop, you'll need some
if/else logic, but whatever you do is fine so long as it produces the correct results.
Transcribed Image Text:Project Description
For this final exam project, you will write a series of functions. For each function, a signature
is given below along with a description of what each function should do. Under no
circumstance should these functions use scanf! Do not read input from the user inside the
function. The functions will operate solely on their input arguments.
0) void promise (char name[])
This function will not return anything. It will accept a string as an argument, and print
out the following message to the screen:
"My name is <your name here>, and I promise that this is entirely my own work"
When I call the function with my own name:
promise("Alex Ufkes");
The message that prints would be:
"My name is Alex Ufkes, and I promise that this is entirely my own work"
Process by which instructions are given to a computer, software program, or application using code.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.