int *int_array = (int *)malloc(sizeof(int) * 40);Write a loop that uses scanf to read 40 integers from stdin directly into the elements of the integer array. In other words, you cannot pass an integer variable to scanf and then assign the integer variable to the appropriate element in the array. That requires an intermediate step and is less efficient than a direct read.
char word; char *string_ptr; int *double_string_ptr; int i; (1) string_ptr = (char *)malloc(sizeof(char) * 50); (2) double_string_ptr = (char **)malloc(sizeof(char *) * 10); for (i = 0; i < 10; i++) double_string_ptr[i] = string_ptr + (i * 5);Further suppose that you are given the following information (all addresses are in base 10):
address of word = 1000 address of string_ptr = 1008 address of double_string_ptr = 1012 address returned by malloc in statement (1) = 5000 address returned by malloc in statement (2) = 6000 sizeof(char) = 1 sizeof(char *) = 4
Dllist my_list = new_dllist(); Dllist one_node = dll_append(my_list, new_jval_i(1)); Dllist two_node = dll_prepend(my_list, new_jval_i(2)); Dllist three_node = dll_insert_a(two_node, new_jval_i(3)); Dllist four_node = dll_insert_b(two_node, new_jval_i(4));
You are to write a function that given two sorted lists of integers, L1 and L2, prints the integers that are common to both lists. For example, if L1 contains the integers 1, 3, 6, 10, 12 and L2 contains the integers 2, 3, 10, 12, 15 then your program should print:
3 10 12You should assume that the lists are stored as Dllists and that the integers are stored in Jvals in the Dllists. The function's prototype is:
void print_common_elements(Dllist L1, Dllist L2);
Dllist reverse(Dllist input_list);