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

I need each of these problems answered. I have the first one answered to show an

ID: 3534865 • Letter: I

Question

I need each of these problems answered.


I have the first one answered to show an example that each answer doesn't need to be a complete program just only what the question asks for.


All of it must be written in C. Thank you!


(2 points)

char choice;

(There is more than one way to do this)

(2 points)

(3 points)

(3 points)

(3 points)

(5 points)

(7 points)

(3points)

10. Write a complete function definition (including the code between braces) for the function named getChoice that has no incoming parameters, but returns a single character as a result. The function should do everything that questions 4 through 6, and 8 accomplish. That is, your function will continually ask a user to enter either ‘Y’ or ‘N’, until they enter a valid answer. That answer is returned to the calling function.

(7 points)

(3 points)

(7 points)

(3 points)

char * choiceP;

14. Write the statement that assigns a blank (‘ ‘) the character variable named choiceP.

(3 points)

*choiceP = ‘ ‘;

15. Write the function prototype for a function named getChoice2 that takes a single pointer to a character variable named theChoice as a parameter. The function does not return any value.

(5 points)

16. Write a function call statement to getChoice2 from Question 15, sending as an argument the variable named choiceP from Question 13.

(3 points)

17. If in the function getChoice from Question 15 we altered the value of theChoice, does that also alter the value of choiceP in main() if it calls getChoice2 (as in Question 16)? Why, or why not?

(2 points)

18. Write a statement that declares a file pointer named myFile.

(3 points)

19. Write a statement that opens a file called “answers.txt†for writing, and assigns it to a file pointer named myFile.

(5 points)

20. Writes a single character value to the file pointed to by myFile. The character to be written is stored in the variable choice from Question 1.

(3 points)

21. Write another single character value to the file pointed to by myFile. The character to be written is stored in the variable choiceP from Question 13.

(3 points)

22. Close the file pointed to by myFile.

(2 points)

23. Open a file called “answers.txt†for reading, and assigns it to a file pointer named myFile.

(5 points)

24. Read a single character value from the file pointed to by myFile and stores it in a variable named choice.

(3 points)

25. Write the function prototype for a function named readFile that returns a character value. The function has one parameter; a file pointer to a file named inFile.

(5 points)

26. Call the function from Question 25, sending as an argument the file pointer from Question 23.

(4 points)

27. Declare an array of 3 integers named intList.

(5 points)

28. Assign the value of 8 to the 1st element in intList.

(5 points)

29. Assign the 2 times the value of x to the last element in intList. Assume that x has already been declared and assigned a valid value.

(5 points)

30. Print to the standard output (screen) the 2nd element in intList.

(5 points)

31. Write a prototype for a function named printList that has two parameters, an integer named howmany, and an array of integers named intList. The function does not return a value.

(5 points)

32. Write a statement that calls the function printList from Question 31 with the value 3 as the 1st argument, and the intList array from Question 27 as the 2nd argument.

(5 points)

33. Write a complete for loop that prints the contents of the array intList from Question 27. Be sure to print each value on a separate line. The index variable in the for loop can be any valid variable name of your choosing. Don’t forget to declare the index variable before using it.

(15 points)

34. In C, a “string†is implemented as an array of characters whose last element is the NULL character. Declare a “string†of chars named animal that can fit an animal name of up to 20 characters.

(5 points)

35. In a single statement, define and assign the literal value “Wabbit†to a string variable named animal.

(5 points)

36. Print a string from the variable named animal to the standard output (screen). Format your output so that the variable is printed with text, like this:

(5 points)

You are a Wabbit. It happens to be Wabbit season.

37. Scan a string from the standard input (keyboard) into a variable named animal. Also include a printf statement so that your format looks something like this:

(5 points)

It is dark. You are likely to be eaten by a: Grue

38. Declare an array of strings named animalist. The array can fit a list of up to 100 animals, each of which can have a name that is up to 20 characters long.

(5 points)

39. Define a struct type named ACCT that contains three variables: An integer named number, a double named balance, and a char named type.

(7 points)

40. Declare a struct variable named myAcct that is of type ACCT, as defined in Question 38.

(3 points)

41. Write the statements that assign some initial value to the number, balance, and type components of the variable myAcct that was declared in Question 39.

(5 points)

42. Scan an integer from the standard input (keyboard) into the number component of the struct variable myAcct from Question 30.

(5 points)

43. Print the value of the number component of the struct variable myAcct from Question 30 to the standard output (screen).

(5 points)

44. Which one of the following string functions copies the string literal “Kitten†to the string variable named animal?

(3 points)

a. strcat( choice, animal );

b. strcmp( animal, “Kitten†);

c. strcpy( animal, “Kitten†);

d. strlen( animal, “Kitten†);

45. What #include is required if string functions will be used in the program?

(2 points)

Explanation / Answer

http://ideone.com/n2o7CM

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote