pts Implement a function called readvalues that has the prototype below The

Pts implement a function called readvalues that has

This preview shows page 5 - 9 out of 11 pages.

13.(9 pts) Implement a function called read_valuesthat has the prototype below. The function will read two integer values separated by a dash and will leave those values in the integers associated with the out parameters v1 and v2. The function returns 1 if the two values can be read and 0 otherwise. int read_values(int *v1, int *v2) 14.(6 pts) What is the output of the following program when the user provides each of the inputs below followed by pressing the enter/return key? Write the output after OUTPUT #include <stdio.h> int main() { float f = 5.0; char c = 'A'; scanf("%f", &f); c = getchar(); printf("V1:%.1fV2:%cEND\n", f, c); return 0; } 15.(8 pts) Complete the following C program where data is provided using command line arguments. The program will print “Even” if the second command line argument is even and “Odd” otherwise. Remember that the atoi() function allows you to get an integer value from a string. The following are examples of running the program you are expected to write. You can assume the user will provide a number after a.out (you do not need to check the correct number of arguments have been provided).% a.out 3 Odd % a.out 4 Even #include <stdio.h> #include <stdlib.h>
Background image
6 16.(21 pts) The function find_nth_instancereturns a pointer to the ninstance (if present) of the character targetin the string str; otherwise the function returns NULL. YOU MAY NOT USE ANY STRING functions from string.h; if you do you will lose most of the points for this question. const char *find_nth_instance(const char *str, char target, int n)
Background image
7 Problem #2 (Memory Map) Draw a memory map for the following program at the point in the program execution indicated by the comment /*HERE */. #include <stdio.h> #define MAX_LEN 4 void process(int *e, int *f, int **g, int h) { int x = f - e, w; h = 1000; w = e - f; *f = 777; f[1] = 333; e = NULL; *g = NULL; /* HERE */ } int main() { int a[MAX_LEN] = {10, 7, 9}, d = 800; int *b = a, *c = a + 2; process(a, c, &c, d); return 0; }
Background image
8 Problem #3 (Structures) The following definitions, associated with a restaurant, will be used for the questions below. A restaurant has a name, number of tables (num_tablesfield), and tables that are available (avail_tablesfield that represents how many tables among num_tablesare not being used). A table keeps track of how many guests are sitting at the table (guests
Background image
Image of page 9

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture