I need a C program that generates all 3,185 solutions based on the following par
ID: 440966 • Letter: I
Question
I need a C program that generates all 3,185 solutions based on the following parameters: The program takes 4 numbers and uses 3 math operators out of the four (*,-,+,/) to equate the numbers to 24. For example, the first number generated should be 1: 1+1+1*8 and the last number generated is 3185: 9*9-9/3; it looks like the program should do the math from left to right, and not order of operations. Due to the first solution generated being 1+1+1*8 would be 3*8=24; PLEASE DON'T USE ARRAYS, I'M NOT ALLOWED TO USE THEMExplanation / Answer
Dear friend, please rate this answer. Also, please do not vote on copied answers. That will waste my time and effort. #include void printop(int op) { if(op==1) printf("+"); else if(op==2) printf("-"); else if(op==3) printf("*"); else if(op==4) printf("/"); } float compute1(float p1,float p2,int op) { if(op==1) return (p1+p2); if(op==2) return (p1-p2); if(op==3) return (p1*p2); if(op==4) return (p1/p2); } float compute(float n1,float n2,float n3,float n4,int op1,int op2,int op3) { return(compute1(compute1(compute1(n1,n2,op1),n3,op2),n4,op3)); } main() { float n1,n2,n3,n4; int o1,o2,o3; for(n1=1;n1Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.