Question
URGENT! Can anyone please do this? Its for linux. I am using Mobaxterm. Like how will I do it? Please tell me the steps. I
URGENT! Can anyone please do this? Its for linux. I am using Mobaxterm. Like how will I do it? Please tell me the steps. I need it for this week. Will upvote.
This was question 1 which I already did. I need help with question 2.
Here are the codes for quadratic, triples and modsum, and cal.c 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 cal.c
#include
#include
#include
int main()
{
float a,b,c,root1,root2,det,real,img;
printf("To Determine the value of x in the Quadratic Equation ax^2-bx+c=0");
printf(" Enter the Coefficient a: ");
scanf("%f",&a);
printf(" Enter the Coefficient b: ");
scanf("%f",&b);
printf(" Enter the Coefficient c: ");
scanf("%f",&c);
det = b*b - 4*a*c;
if(det
{
real = -b/(2*a);
img = sqrt(-det)/(2*a);
printf(" Value of root1 is = %0.3f + %0.3fi and value of root2 is = %0.3f - %0.3fi ",real,img,real,img);
}
else if(det == 0)
{
root1 = root2 = -b / (2 * a); // both roots are equal;
printf(" Value of root1 = %0.3f and Value of root2 = %0.3f", root1, root2);
}
else
{
root1 = (-b + sqrt(det)) / (2 * a);
root2 = (-b + sqrt(det)) / (2 * a);
printf(" Value of root1 = %0.3f and value of root2 = %0.3f", root1, root2);
}
getch();
return 0;
}
a 2 Program Preparation Prepare a makefile for compiling the program comprised of quadratic.c, triples.c, sum.c, and cal.c or cal.cpp". The generated executable should be named as cal.exe. Then, write a shell script "execute to compile the program using the "make" command and execute cal.exe with an input file cal.in. In your script, the execution of cal.exe should be done twice. In the first invocation of cal.exe, let the output be redirected to cal.out. In the second invocation of cal.exe, pipe the output to the fgrep command and find string s in the output. Your script execute should take string s as an input argument. Note that you should not use #include to include the three C code files into your cal.c or cal.cpp. You should compile each C code file into an object code file (.0") separately and then link the .o files together. 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started