Task 1: Convert a number string to number
Write a C function str_to_float() that takes a numeric string as input and converts it to a floating point number. The function should return the floating point number by reference. If the conversion is successful, the function should return 0, and -1 otherwise (e.g. the string does not contain a valid number). The prototype of the function is given below
int str_to_float(char * str, float * number);
Task 2: Test for Palindrome (recursive)
Write a function isPalindrom() that takes as input a C string and its size, and recursively tests whether it is a palindrome (a word or phrase which remains the same if reversed. e.g. radar, kayak etc). The function returns the Boolean data type which is either true or false. The required header “stdbool.h” has already been included in tasks.h.
The function has the following prototype:
bool isPalindrom(char * ptr_array, int size);
The recursive definition of a palindrome is:
The string is a palindrome if it has only one character or is an empty string.
The string is a palindrome if the first and the last characters are the same and the characters in between form a palindrome
Task 1: Reverse a character string.
Write a function called str_rev() that takes a pointer to a string as input and reverses the string in-place (this change should be reflected in the original string that was passed to the function, not to a copy of the string). No library functions for string reversal should be used. The function should also return a pointer to the reversed string.
Function prototype is given below:
char * str_rev(char * str);
Let A and B be the two matrix. The size of matrix A is m and size of matrix B. Then, find subtraction of C, is a A and B is defined as C(ij) = A(ij) - B(ij).
From a set of array elements, find the number of occurrences of each element present in the given array.
C programming , Let A and B be the two matrix. The size of matrix A is m and size of matrix B. Then, find subtraction of C, is a A and B is defined as C(ij) = A(ij) - B(ij).
The Air Force has asked you to write a program to label aircrafts as military or civilian. Your program input is the plane's speed and its estimated length. For planes traveling faster than 1100 km/hr, you will label those shorter than 52 m “military", and longer as “Civilian". For planes traveling less than 1100, you will issue an “aircraft unknown" statement.
Your task is to declare a 2D array whose dimensions should be entered by the user of the program.
• Then you should initialize the array with ones (using nested loops).
• Next you have to write a function array_multiply() which takes in the array or its pointer as argument and multiplies all its entries with a user input number. (Hint: you will also need to pass in the dimensions of the matrix to this function).
• Similarly write a function array_add() that adds a constant number to all the entries in a 2D array.
• Print the results of calling these functions.
Exercise 2 : Mining Temperature Data
The highs and lows of the 3 first weeks of 2020 temperature data are available on a piece paper and we have decided to store
them in a three-dimensional array in which the first index represents the 3 first weeks of the year, and take the value from 0 to
2; the second index is numbered 0 through 6 and represents the days of the week, and the last index which is numbered 0 and
1, represents the day’s high and low temperatures, respectively.
(2.1) Write a C program that enables you to capture the 3 first weeks of 2020 temperature data, from the keyboard, and store
them in the array described above. You must check the validity of any data entered.
(2.2) Write functions to request the following:
(a) Any day’s high and low temperature
(b) Average high and low temperature for given week
(c) Week and day with the highest temperature
(d) Week and day with the lowest temperature
(2.3) Write a driver program to test your functions defined in (2.1) and (2.2).
Your second task is to implement the Insertion Sort algorithm by making a function with the following prototype; void insertion_sort(int * ptr_array, int size, int order); This function takes as input a pointer to the start of the array, and the array size and sorts it inplace. The last input to the function is the sorting order (0 for ascending and 1 for descending).