Question: func_ptr.c : Please code in C Task Overview Task-1: Your first task is to complete the comparer function in the func-ptr.c file present in the

 func_ptr.c : Please code in C Task Overview Task-1: Your first

func_ptr.c :

task is to complete the comparer function in the func-ptr.c file presentin the provided source code. The details of this assignment are providedin the lab3.pdf slides. Task-2: Write a program that takes a single

Please code in C

Task Overview Task-1: Your first task is to complete the comparer function in the func-ptr.c file present in the provided source code. The details of this assignment are provided in the lab3.pdf slides. Task-2: Write a program that takes a single character 'O', '1', '2', '3") from the user as input, and based on the character it performs the following operation (on two pre-defined integers): 'O' - add '1'- subtract '2' - multiply '3' - divide '4' - exit program **Please note that you are not allowed to use any conditional statements (e.g. if-else, switch-case, goto etc.) in your program. You must insert your code for this task in the task2.c file included in the lab template. Run task2 using the command./func_ptr from the command prompt ** 1 2 3 #include #include #include #include 3 4 5 6 #include "process.h" #include "util.h" 7 8 9 #define DEBUGO // change this to 1 to enable verbose output 10 11 12 13 14 15 /** * Signature for an function pointer that can compare * You need to cast the input into its actual * type and then compare them according to your * custom logic */ typedef int (*Comparer) (const void *a, const void *b); 16 17 18 19 20 21 /** * compares 2 processes * You can assume: Process ids will be unique No 2 processes will have same arrival time */ * 22 23 * 24 35 36 int main(int argc, char *argv[]) { 37 38 39 40 41 if (argc "); fflush(stdout); return 1; } 42 43 44 45 46 47 48 49 50 51 52 53 /****** *****/ /* Parse the input */ /******* *****/ FILE *input_file = fopen(argv[1], "r"); if (!input_file) { fprintf(stderr, "Error: Invalid filepath "); fflush(stdout); return 1; } 54 55 Process *processes = parse_file(input_file); 56 57 58 /******* *****/ /* sort the input */ /******** *****/ Comparer process_comparer = 59 60 &my_comparer; 61 62 63 #if DEBUG for (int i = 0; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!