Question: URGENT! Can anyone please do the main code in language C? Its for linux. I need it for this week. Will upvote. Here are the

URGENT! Can anyone please do the main code in language C? Its for linux. I need it for this week. Will upvote.
Here are the codes for quadratic, triples and modsum in C.
quadratic.c
#include#include // this function finds the roots for quadratic function ax^2 + bx + c void quadratic_solution (int a, int b, int c) { double fa = (double) a; double fb = (double) b; double fc = (double) c; double x = fb * fb - 4 * fa * fc; double s1 = ( - fb + sqrt (x) ) / (2*fa); double s2 = ( - fb - sqrt (x) ) / (2*fa); printf ("(%d, %d, %d) solutions = %f, %f ", a, b, c, s1, s2); // int count = 0; // if ( s1 == rint(s1) ) count++; // if ( s2 == rint(s2) ) count++; // printf ("%d integer solutions ", count); } void solve_quadratic (int b, int c) { quadratic_solution (1, b, c); }
triples.c
#include#include // this program finds the Pythagorean triples with max values mx and my int is_square (int x, int y) { double tx, ty, tz, tr, r; tx = (double) x; ty = (double) y; tz = tx * tx + ty * ty; tr = sqrt (tz); if ( tr == rint(tr) ) return ((int) tr); else return (0); } int relatively_prime (int x, int y) { int tmp, r; if (x sum.c
#include// compute sum from 1 to n // integer mod is used to prevent the sum go over max integer void modular_sum (int n, int mod) { int sum, i; sum = 0; for (i=1; i 1 The Cal Process a > = You need to create a program "cal.c or cal.cpp to perform some calculations. The input file is cal.in. The file contains M + 1 lines. The first line contains a single integer, M. The following M lines are the computing commands. Each line includes a command and 2 integers. The command can be quadratic, triples", or mod-sum. Function quadratic finds the 2 roots of x2 + ax + b and a and b are the two b integers given in the same line. Function triples finds a list of Pythagorean triples that satisfies x2 + y2 z?, with x, y,z all being integers. The two input integers are the maximum values for x and y. Function mod-sum computes En=1n % mod and x and mod are the two integers given in the same line. The C code for quadratic, triples, and sum functions are given in files quadratic.c, triples.c, and sum.c, respectively. You just need to implement the main program in another file cal.c or cal.cpp. 2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
