New C Library Documentation

INDEX




bin.h



Parameters: (int destination_array, int array_size,int decimal_number)
Return type: int array
Function description: Returns the binary equivalent for the decimal number passed to the function.
Example: a[n]= dec_to_bin(a, n, dec);
Parameters: (int source_array, array_size)
Return type: int
Function description: Returns the decimal equivalent for the binary number referenced by the array name passed to the function.
Example: int dec= bin_to_dec(arr, n);
Parameters: (int destination_array, int source_array,int array_size)
Return type: int array
Function description: Calculates one’s complement of the binary number passed as the source array and stores it in the passed destination array. The contents of the source array remain intact.
Example: a[n] = *ones_complement(a,array,n);
Parameters: (int destination_array,int source_array,int array_size)
Return type: int array
Function description: Calculates two’s complement of the binary number passed as the source array and stores it in the passed destination array. The contents of the source array remain intact.
Example: a[n] = *twos_complement(a,array,n);
Parameters: (int destination_array,int destination_array_size, int source_array1, int source_array1_size,int source_array2, int source_array2_size)
Return type: int array
Function description: Calculates the sum of the two binary numbers passed as source arrays and stores this sum in the passed destination array. The contents of the source arrays remain intact.
Example: a[n] = *bin_add(a, n, arr1, n1, arr2, n2);
Parameters: (int destination_array,int destination_array_size, int source_array1, int source_array1_size,int source_array2, int source_array2_size)
Return type: int array
Function description: Calculates the difference of the two binary numbers passed as arrays and stores this difference in the passed destination array. The function calculates the greater of the two binary numbers and then calculates the difference. This is done in order to negate the use of any one’s or two’s complement representations of the difference. The contents of the source arrays remain intact.
Example: a[n] = *bin_diff(a, n, arr1, n1, arr2, n2);
Parameters: (int destination_array,int destination_array_size, int source_array1, int source_array1_size,int source_array2, int source_array2_size)
Return type: int array
Function description: Calculates the product of the two binary numbers passed as arrays and stores this product in the passed destination array. The contents of the source arrays remain intact.
Example: a[n] = *bin_mult(a, n, arr1, n1, arr2, n2);
Parameters: (int destination_array,int destination_array_size, int source_array, int source_array_size)
Return type: int array
Function description: Converts binary number passed as source array to its equivalent octal number and stores it in the destination array.
Example: a[n] = *bin_to_octa(a, n, array, n1);
Parameters: (int destination_array ,int destination_array_size, int source_array, int source_array_size)
Return type: int array
Function description: Converts octal number passed as source array to its binary equivalent and stores it in the destination array
Example: a[n] = *octa_to_bin(a,n,array,n1);
Parameters: (char destination_array,int destination_array_size, int source_array, int source_array_size)
Return type:char array
Function description: Converts binary number passed as source array to its equivalent hexadecimal no. and stores it in the destination array.
Example: a[n] = *bin_to_hexa(a,n,array,n1);
Parameters: (int destination_array ,int destination_array_size, int source_array, int source_array_size)
Return type: int array
Function description: Converts hexadecimal number passed as source array to its binary equivalent and stores it in the destination array.
Example: a[n] = *hexa_to_bin(a,n,array,n1);
Parameters: (int destination_array,int destination_array_size, int decimal_number)
Return type:int array
Function description: Converts decimal number to its equivalent hexadecimal number and stores it in the destination array.
Example: a[n] = *dec_to_octa(a, n, dec);
Parameters: (int source_array, int source_array_size)
Return type: int
Function description: Converts octal number passed as source array to its equivalent decimal number.
Example: dec = octa_to_dec(array, n1);
Parameters: (char destination_array,int destination_array_size, int decimal_number)
Return type:char array
Function description: Converts decimal number to its equivalent hexadecimal number.
Example: a[n] = *dec_to_hexa(a,n,no);
Parameters: (char source_array,int source_array_size)
Return type: int
Function description: Converts hexadecimal number passed as source array to its equivalent decimal number.
Example: dec = hexa_to_dec(array,n1);
Parameters: (char destination_array,int destination_array_size, int decimal_number)
Return type:int array
Function description: Calculates the 7 bit hamming code of the 4 data bits passed as source array. The source array must be stored as: [D7, D6, D5, D3] and the hamming code will be returned as [D7, D6, D5, P4, D3, P2, P1]. The parity bit must either be 0 or 1(0: Even parity, 1: Odd parity).
Example: a[n] = *hamming_7(a, n, array, n1, parity);
Parameters: (int destination_array,int destination_array_size, int source_array, int source_array_size, int parity)
Return type: int array
Function description: Calculates the 12 bit hamming code of the 8 data bits passed as source array. The source array must be passed as: [D12, D11, D10, D9, D7, D6, D5, D3] and the hamming code will be returned as [D12, D11, D10, D9, P8, D7, D6, D5, P4, D3, P2, P1]. The parity bit must either be 0 or 1(0: Even parity, 1: Odd parity).
Example: a[n] = *hamming_12(a, n, array, n1, parity);








array.h


Parameters: (int source_array, int array_size)
Return type: int
Function description: Returns the minimum element in the integer array passed to the function.
Example: int min= array_min_int(arr, n);
Parameters: (float source_array, int array_size)
Return type: float
Function description: Returns the minimum element in the float array passed to the function.
Example: float min= array_min_float(arr, n);
Parameters: (int source_array, int array_size)
Return type: int
Function description: Returns the maximum element in the integer array passed to the function.
Example: int min= array_min_int(arr, n);
Parameters: (float source_array, int array_size)
Return type: float
Function description: Returns the maximum element in the float array passed to the function.
Example: float max= array_max_float(arr, n);
Parameters: (int source_array, int array_size)
Return type: -
Function description: Sorts the integer array passed to the function in the ascending order .
Example: array_asc_sort_int(arr, n);
Parameters: (int source_array, int array_size)
Return type: -
Function description: Sorts the integer array passed to the function in the descending order .
Example: array_desc_sort_int(arr, n);
Parameters: (float source_array, int array_size)
Return type: -
Function description: Sorts the float array passed to the function in the ascending order .
Example: array_asc_sort_float(arr, n);
Parameters: (float source_array, int array_size)
Return type: -
Function description: Sorts the float array passed to the function in the descending order .
Example: array_desc_sort_float(arr, n);
Parameters: (int source_array, int array_size, int target_element)
Return type: int
Function description: Searches for a particular element in the int array passed in the function. Returns the index if found, else returns -1.
Example: array_search_int(arr, n, find);
Parameters: (float source_array, int array_size, float target_element)
Return type: int
Function description: Searches for a particular element in the float array passed in the function. Returns the index if found, else returns -1.
Example: array_search_float(arr, n, find);
Parameters: (char source_array, int array_size, char target_element)
Return type: char
Function description: Searches for a particular element in the character array passed in the function. Returns the index if found, else returns -1.
Example: array_search_char(arr, n, find);
Parameters: (int source_array, int array_size)
Return type: float
Function description: Returns the average of all the integer array elements
Example: int avg = array_avg_int(arr, n);
Parameters: (float source_array, int array_size)
Return type: float
Function description: Returns the average of all the float array elements
Example: float avg = array_avg_float(arr, n);
Parameters: (int source_array, int array_size)
Return type: int
Function description: Returns the sum of all the integer array elements
Example: int sum = array_sum_int(arr, n);
Parameters: (float source_array, int array_size)
Return type: float
Function description: Returns the sum of all the float array elements
Example: float sum = array_sum_float(arr, n);
Parameters: (int source_array, int array_size)
Return type: -
Function description: The elements of the integer array are reversed.
Example: array_reverse_int(a, n);
Parameters: (float source_array, int array_size)
Return type: -
Function description: The elements of the float array are reversed.
Example: array_reverse_float(a, n);

Parameters: (char source_array, int array_size)
Return type: -
Function description: The elements of the character array are reversed.
Example: array_reverse_char(a, n);

Parameters: (int a[], int n, int arr1[], int n1, int arr2[], int n2)
Return type: int array
Function description: The elements of the source arrays arr1 and arr2 are merged and stored in destination array a.
Example: array_merge_int(a, n, arr1, n1, arr2, n2);

Parameters: (float a[], int n, float arr1[], int n1, float arr2[], int n2)
Return type: float array
Function description: The elements of the source arrays arr1 and arr2 are merged and stored in destination array a.
Example: array_merge_float(a, n, arr1, n1, arr2, n2);
Parameters: (char a[], int n, char arr1[], int n1, char arr2[], int n2)
Return type: char array
Function description: The elements of the source arrays arr1 and arr2 are merged and stored in destination array a.
Example: array_merge_float(a, n, arr1, n1, arr2, n2);

Parameters: (int a[], int n)
Return type: -
Function description: The elements of the array are shifted one position to the left. The last element of the array is then initialised to 0.
Example: array_shift_left_int(a, n);

Parameters: (float a[], int n)
Return type: -
Function description: The elements of the array are shifted one position to the left. The last element of the array is then initialised to 0.
Example: array_shift_left_float(a, n);

Parameters: (char a[], int n)
Return type: -
Function description: The elements of the array are shifted one position to the left. The last element of the array is then initialised to 0.
Example: array_shift_left_char(a, n);

Parameters: (int a[], int n)
Return type: -
Function description: The elements of the array are shifted one position to the right. The first element of the array is then initialised to 0.
Example: array_shift_right_int(a, n);

Parameters: (float a[], int n)
Return type: -
Function description: The elements of the array are shifted one position to the right. The first element of the array is then initialised to 0.
Example: array_shift_right_float(a, n);

Parameters: (char a[], int n)
Return type: -
Function description: The elements of the array are shifted one position to the right. The first element of the array is then initialised to 0.
Example: array_shift_right_char(a, n);

Parameters: (int a[], int n)
Return type: -
Function description: The elements of the array are rotated one position to the left. The last element of the array is then initialised with the value of the first element of the array.
Example: array_rotate_left_int(a, n);

Parameters: (float a[], int n)
Return type: -
Function description: The elements of the array are rotated one position to the left. The last element of the array is then initialised with the value of the first element of the array.
Example: array_rotate_left_float(a, n);

Parameters: (char a[], int n)
Return type: -
Function description: The elements of the array are rotated one position to the left. The last element of the array is then initialised with the value of the first element of the array.
Example: array_rotate_left_char(a, n);
Parameters: (int a[], int n)
Return type: -
Function description: The elements of the array are rotated one position to the right. The first element of the array is then initialised with the value of the last element of the array.
Example: array_rotate_right_int(a, n);

Parameters: (float a[], int n)
Return type: -
Function description: The elements of the array are rotated one position to the right. The first element of the array is then initialised with the value of the last element of the array.
Example: array_rotate_right_float(a, n);

Parameters: (char a[], int n)
Return type: -
Function description: The elements of the array are rotated one position to the right. The first element of the array is then initialised with the value of the last element of the array.
Example: array_rotate_right_char(a, n);

Parameters: (int row,int column,int matrix)
Return type: void
Function description: Read and store element in the 2D Array.
Example: int_read_mat(r,c,mat);
Parameters: (int row,int column,float matrix)
Return type: void
Function description: Read and store element in the 2D Array.
Example: float_read_mat(r,c,mat);
Parameters: (int row,int column,int matrix)
Return type: void
Function description: Print the 2D Array.
Example: int_prt_mat(r,c,mat);
Parameters: (int row,int column,float matrix)
Return type: void
Function description: Print the 2D Array.
Example: float_prt_mat(r,c,mat);
Parameters: (int row1,int column1,int row2,int column2,int addmatrix,int matrix1,int matrix2)
Return type: void
Function description: Add elements of two matrices and put it in resultant matrix.
Example: int_add_mat(r1,c1,r2,c2,addmat,mat1,mat2);
Parameters: (int row1,int column1,int row2,int column2,float addmatrix,float matrix1,float matrix2)
Return type: void
Function description: Add elements of two matrices and put it on resultant matrix.
Example: float_add_mat(r1,c1,r2,c2,addmat,mat1,mat2);
Parameters: (int row1,int column1,int row2,int column2,int submatrix,int matrix1,int matrix2)
Return type: void
Function description: Subtract elements of two matrices and put it on resultant matrix.
Example: int_sub_mat(r1,c1,r2,c2,submat,mat1,mat2);
Parameters: (int row1,int column1,int row2,int column2,float submatrix,float matrix1,float matrix2)
Return type: void
Function description: Subtract elements of two matrices and put it on resultant matrix.
Example: float_sub_mat(r1,c1,r2,c2,submat,mat1,mat2);
Parameters: (int row1,int column1,int row2,int column2,int mulmatrix,int matrix1,int matrix2)
Return type: void
Function description: multiply two matrices and put it on resultant matrix.
Example: int_mul_mat(r1,c1,r2,c2,mulmat,mat1,mat2);
Parameters: (int row1,int column1,int row2,int column2,float mulmatrix,float matrix1,float matrix2)
Return type: void
Function description: multiply two matrices and put it on resultant matrix.
Example: float_mul_mat(r1,c1,r2,c2,mulmat,mat1,mat2);
Parameters: (int row,int column,int trmatrix,int matrix)
Return type: void
Function description: transpose of matrix and put it on resultant matrix.
Example: int_transpose_mat(r,c,trmat,mat);
Parameters: (int row,int column,float trmatrix,float matrix)
Return type: void
Function description: transpose of matrix and put it on resultant matrix.
Example: float_transpose_mat(r,c,trmat,mat);
Parameters: (int row,int column,int comatrix,int matrix)
Return type: void
Function description: calculate the cofactor of matrix and put it on resultant matrix.
Example: int_cofactor_mat(r,c,comat,mat);
Parameters: (int row,int column,float comatrix,float matrix)
Return type: void
Function description: calculate the cofactor of matrix and put it on resultant matrix.
Example: float_cofactor_mat(r,c,comat,mat);
Parameters: (int row,int column,int matrix)
Return type: int
Function description: calculate the determinant of matrix and return it to main function.
Example:int x = int_determinant_mat(r,c,mat);
Parameters: (int row,float column,float matrix)
Return type: float
Function description: calculate the determinant of matrix and return it to main function.
Example:float x= float_determinant_mat(r,c,mat);
Parameters: (int row,int column,int inverse,int matrix)
Return type: void
Function description: calculate the inverse of matrix and put it on resultant inverse matrix.
Example: int_inverse_mat(r,c,inverse,mat);
Parameters: (int row,int column,float inverse,float matrix)
Return type: void
Function description: calculate the inverse of matrix and put it on resultant inverse matrix.
Example: float_inverse_mat(r,c,inverse,mat);








vector.h



Parameters: -
Return type: struct vector *
Function description: Creates a vector and returns its start address.
Example: struct vector* vname = create_vector();
Parameters: (vector_name, data_to_insert)
Return type: void
Function description: Inserts data to first position of passed vector.
Example:
insert_first(vname , 12);
insert_first(vname, 32.0011);
insert_first(vname, 'c');
Parameters: (vector_name, data_to_insert)
Return type: void
Function description: Inserts data to last position of passed vector.
Example:
insert_last(vname , 12);
insert_last(vname, 32.0011);
insert_last(vname, 'c');
Parameters: (vector_name, index, data_to_insert)
Return type: void
Function description: Inserts data at said index of passed vector.
Example:
insert_at(vname , 1, 12);
insert_at(vname, 2, 32.0011);
insert_at(vname, 3, 'c');
Parameters: (vector_name)
Return type: void
Function description: Deletes data at first position of passed vector.
Example: delete_first(vname);
Parameters: (vector_name)
Return type: void
Function description: Deletes data at last position of passed vector.
Example: delete_last(vname);
Parameters: (vector_name, index)
Return type: void
Function description: Deletes data at said index of passed vector.
Example: delete_at(vname, 1);
Parameters: (vector_name, data)
Return type: int
Function description: Removes the first occurrence of passed data and returns the deleted position. Returns -1 if not present.
Example: remove_first_occurr(vname, 45);
Parameters: (vector_name, data)
Return type: int
Function description: Removes the last occurrence of passed data and returns the deleted position. Returns -1 if not present.
Example: remove_last_occurr(vname, 45);
Parameters: (vector_name, index, new_data)
Return type: void
Function description: Replaces the data at said index with new_data.
Example: replace_at(vname, 2, 45);
Parameters: (vector_name)
Return type: void
Function description: Prints all vector data in integer format.
Example: display_int(vname);
Parameters: (vector_name)
Return type: void
Function description: Prints all vector data in character format.
Example: display_char(vname);
Parameters: (vector_name)
Return type: void
Function description: Prints all vector data in float format.
Example: display_float(vname);
Parameters: (vector_name, data)
Return type: int
Function description: Returns 1 if data is present 0 if not present.
Example: contains(vname, 67);
Parameters: (vector_name, data)
Return type: int
Function description: Returns the position of first occurrence of passed data. Returns -1 if data is not present.
Example:int first = index_of(vname, 32);
Parameters: (vector_name, data)
Return type: int
Function description: Returns the position of last occurrence of passed data. Returns -1 if data is not present.
Example:int last = last_index_of(vname, 67);
Parameters: (vector_name)
Return type: float
Function description: Returns the value at first position of passed vector in float data type. To store/display returned value in other data type, use type-casting as shown in example.
Example:
float f = get_first(vname);
int f = (int)get_first(vname);
char f = (char)get_first(vname);
Parameters: (vector_name, data)
Return type: float
Function description: Returns the data at last position of passed vector in float data type. To store/display returned value in other data type, use type-casting as shown in example.
Example:
float l = get_last(vname);
int l = (int)get_last(vname);
char l = (char)get_last(vname);
Parameters: (vector_name, index)
Return type: float
Function description: Returns the value at said position of passed vector in float data type. To store/display returned value in other data type, use type-casting as shown in example.
Example:
float a = get_at(vname, 2);
int a = (int)get_at(vname, 2);
char a = (char)get_at(vname, 2);
Parameters: (vector_name)
Return type: int
Function description: Returns the length (i.e No. of elements) in passed vector.
Example:int l = vector_length(vname);
Parameters: (vector_name)
Return type: struct vector *
Function description: Clones the passed vector onto a new vector and returns the start address of new vector.
Example: struct vector* new_vname = clone_vector(old_vname);
Parameters: (vector_name)
Return type: void
Function description: Deletes the contents of passed vector
Example:clear_vector(vname);