c in c programming language using the same func and pointers

Answer all Questions For each of the following questions, you can find: 1. Description of the requirements. 2. Testing example(s). 3. Function prototype that you should write your code inside it. The function already declared and defined in the given start-up code. 4. Helper function(s), if any, that can be used in the solution. 5. Evaluation marks. Q 1 Find Occurrences Name: focc Description: • This command should search for the given substring in string and then return the number of occurrences of this substring if found or zero if not found. • is sample statement • contains a character or more that we need to find the number of its occurrences in Notes: • The given string contains multiple words separated by underscore; i.e. the underscore acts here exactly as if spaces exist between words • The substring is not necessary be exist in the given string and in this case return 0 Example: FOS> focc hello_world ld ➔ 1 (hello_world) FOS> focc hello_world l ➔ 3 (hello_world) FOS> focc hello_world_o_w o_w ➔ 2 (hello_world_o_w) FOS> focc hellohellohellohello lo ➔ 4 (hellohellohellohello) FOS> focc operating_systems ss ➔ 0 (Not exist) FOS> focc defenselessness ss ➔ 2 (defenselessness) FOS> focc ppppppp pp ➔ 3 (ppppppp) Page 2 of 5 Function: Your code MUST be written inside the following function: int FindNoOcc(int num_of_args, char** arguments) 1. arguments[1]: A string 2. arguments[2]: A substring we need to find the number of its occurrences Return: Number of occurrences of the given substring in a sample input string Evaluation: a) Correct code logic [2 marks] b) Successful run [3 marks] [Q1 Total: 5 marks] Q 2 Calculate Array Variance Name: cav Description: • This command should calculate the variance ( 2 ) of the elements in the given , according to the following equation: = 2 () = ∑ ([] − ()) 2 −1 =0 Where: ▪ N: array size ▪ (): is the mean (average) of the array elements: = () = ∑ [] −1 =0 • NOTEs: 1. use integer data types (no float, no double) 2. cnia is already implemented inside the given code Example: FOS> cnia x 3 10 20 30 FOS> cnia y 4 400 400 FOS> cav x //should print 66 FOS> cav y //should print 40,000 Page 3 of 5 Function: Your code MUST be written inside the following function: int CalcArrVar(char** arguments) arguments[1]: array name Helper Functions: • strcmp(const char *p, const char *q): to compare string p to string q Evaluation: a) Correct code logic [2 marks] b) Successful run [3 marks] [Q2 Total: 5 marks] Q 3 Count free pages inside a table Name: cfpDescription: This command should count the number of free pages inside the given. A free page is the one that’s not connected to any frame. If the table is not exists, you should return -1. Example: FOS> cfp 960 (number of free pages inside table # 960 = 0) FOS> cfp 0 (table is not exists, it should return -1) Function: Your code MUST be written inside the following function: int CountFreePagesInTable(char** arguments) 1. arguments[1]: table number Return: 2. If table exists, return number of free pages. 3. Else, return -1. Page 4 of 5 Evaluation: a) Correct code logic [2 marks] b) Successful run [3 marks] [Q3 Total: 5 marks] Q 4 Count modified pages in a virtual range Name: cmps Description: This command should count the number of modified pages inside the given virtual range [, ). Example: FOS> cmps F0000000 F0005000 ➔ (no modified pages in this range) FOS> wum 0xF0000000 A ➔ write ‘A’ at F0000000 (1st page in the range) FOS> wum 0xF0000005 B ➔ write ‘B’ at F0000005 (still in the 1st page) FOS> wum 0xF0003000 C ➔ write ‘C’ at F0003000 (4th page in the range) FOS> wum 0xF0004FFF D ➔ write ‘D’ at F0004FFF (last byte in the 5th page in the range) FOS> cmps F0000000 F0005000 ➔ (num of modified pages in this range = 3) FOS> wum 0xF0005000 X ➔ write ‘X’ at F0005000 (page outside the range) FOS> cmps F0000000 F0005000 ➔ (num of modified pages in this range = 3) Function: Your code MUST be written inside the following function: int CountModifiedPagesInRange(char** arguments) 1. arguments[1]: start virtual address of the range (in HEX) 2. arguments[2]: end virtual address of the range (in HEX) Page 5 of 5 Return: 3. number of modified pages in the given range Helper: 1. You may need to use PERM_MODIFIED 2. There’s a constant in the code called “PAGE_SIZE” which equal to 4KB 3. You can use “ROUNDDOWN” and “ROUNDUP” functions, described below in order to round the virtual addresses on multiple of PAGE_SIZE (4 KB) Function Description Defined in… ROUNDUP (value, align) Rounds a given “value” to the nearest upper value that is divisible by “align”. Inc/types.h ROUNDDOWN (value, align) Rounds a given “value” to the nearest lower value that is divisible by “align”. Inc/types.h Evaluation: a) Correct code logic [2 marks] b) Successful run [3 marks] [Q4 Total: 5 marks] Wishing to you all the best