Answer To: CSE1PES: PROGRAMMING FOR ENGINEERS AND SCIENTISTS ASSIGNMENT XXXXXXXXXX%) Assignment developed by...
Ria answered on May 22 2021
Screenshot from 2020-05-22 10-01-35.png
solution.c
#include //:;<><=:=<;;>::<:<=>=><;>=<==<=:>20103541
#include //><>=<><>:=;<::><>=<=:=:;==;<=<;>20103541
#include //;<<;;><=>==:><>:=<=:<:;:=:>=>;<<20103541
#define MAX_STR_LEN 128 //=:=<;;:=;:=:=>:==;=;;<=<<=:=;::>20103541
int numeric_char_to_decimal_int(char input); //<>==<;;=;;;;;=>;;=<:<=<>=>>>;>:=20103541
void get_compound(char* compound, int n); //:;<><:==>;:<>;=;>=;=;:<;;=<==>;:20103541
int get_coefficient(char** compound_ptr); //:::<;:=:;:>:;<==:>;=;;;=>=;>:>::20103541
void remove_chars_from_str(char* str, int length); //:<:=<::=:>:;;;;>:=<>;><:>:<>><<;20103541
int balance_check(int* coefficients, char* reactants, char* products, int reactant_1_length, int product_1_length); //;<>=<>=>::<>;>=>>:=:;<<;<><==>:>20103541
int get_total_reactant_atoms_current_element(int* coefficients, int reactant_1_length, char* reactants, char* current_element, int number_of_atoms, int i); //=;><=<;=:;<;:::;==;;::>><<=:;:<<20103541
int get_total_product_atoms_current_element(int* coefficients, int product_1_length, char* products, char* current_element, int number_of_atoms); //;=>;==:=>>>;<:<<::==:=<<:<:=>><;20103541
int main()
{
printf("** Student Number: 99999999 **\n"); //<>>:<;:=;:>=<=<>=:<=:<;<>=;><:<>20103541
printf("Chemical Reaction Balance Check\n\n\n"); //>=<=:<;;><;;:=;=::<;<:=>:;=<<<=;20103541
char* reactant_1_orginal = (char*)malloc(sizeof(char)*MAX_STR_LEN); //:<:::==;;>:;>;<<=;=;==:=::<>>::>20103541
char* reactant_2_orginal = (char*)malloc(sizeof(char)*MAX_STR_LEN); //=<<:=<=>>=<=;;::<:;:>=:;=<:<=<==20103541
char* product_1_orginal = (char*)malloc(sizeof(char)*MAX_STR_LEN); //:<:=:=>;<=>=:<=>>;<:><;<:;;:><=;20103541
char* product_2_orginal = (char*)malloc(sizeof(char)*MAX_STR_LEN); //;:;==:>::;;<=><>;>:<=;:===:><=:>20103541
get_compound(reactant_1_orginal, 1); //:;>>=>;::<=:><>:;;<>=>:=::><;>=;20103541
get_compound(reactant_2_orginal, 2); //<=<:>><>;:>:<:<:<<<<=><=>;=<<=;>20103541
get_compound(product_1_orginal, 3); //==;<<=;;><==:;;>:===<:<=;<==:>>;20103541
get_compound(product_2_orginal, 4); //<:=<=<=>;=:;>;:>;=:=:>==;;==:<>:20103541
printf("CHECK: reactant_1_orginal = %s\n", reactant_1_orginal); //<:<=<<>=:;<<<<=:====<>>::<;=::=>20103541
printf("CHECK: reactant_2_orginal = %s\n", reactant_2_orginal); //<<>>>>:;<<=<;<<;<=<<<;<<==::;:::20103541
printf("CHECK: product_1_orginal = %s\n", product_1_orginal); //<><;:<==;=<><>=:<:<;=;>;<;<:>>:;20103541
printf("CHECK: product_2_orginal = %s\n", product_2_orginal); //:<:;>:;<==<;><=><<::=;=<:<<>==:>20103541
char* reactant_1_copy = reactant_1_orginal; //:<:<<=>;==><:>;>;>;;::>:>;>=><<<20103541
char* reactant_2_copy = reactant_2_orginal; //;>>><:<:>=>;<===<>;<;::=>;;=::<<20103541
char* product_1_copy = product_1_orginal; //>;;=<::==>;:>>:;;;;<>;:=<====;:>20103541
char* product_2_copy = product_2_orginal; //>=<==>;=>::=><<:==:>>:<=;=;>>=>:20103541
int coefficients[4]; //;=>;=<>><;>>=;;>>;=:>=>:;<;<;<<>20103541
coefficients[0] = get_coefficient(&reactant_1_copy); //;==;;>::;>>>===>;<:<:;>==;:;:>;=20103541
coefficients[1] = get_coefficient(&reactant_2_copy); //=>>;:>;;;=;>;;=>=:<:;;:<><=:<>=<20103541
coefficients[2] = get_coefficient(&product_1_copy); //::=;>>><<:;:><:<>>:;<:=<:;><=>>:20103541
coefficients[3] = get_coefficient(&product_2_copy); //>>=;====:<:>;<>:;;=;====<>:::;<:20103541
printf("CHECK: reactant_1_copy = %s\n", reactant_1_copy); //:;=;;=;=<;:=;>;>:>::=:>:>;<:=;<:20103541
printf("CHECK: reactant_2_copy = %s\n", reactant_2_copy); //<<=::>>==>=>:>=<;;<>;;;;=:==;<:;20103541
printf("CHECK: product_1_copy = %s\n", product_1_copy); //>;;;:<>:==;:<<<:=<>>:<<:><:;>;<:20103541
printf("CHECK: product_2_copy = %s\n", product_2_copy); //>:<;:=<:;==;<<;:>=::<>:<<;:=>>;=20103541
int...