1 HW #1 Assignment (9 problems) Due: Wed., 09/23/2020 for both Sessions 002 and 003. Write C code that does the following: 1. Interactively read the three coefficients of a quadratic equation and...

1 answer below »
Write C code that does the following:


1 HW #1 Assignment (9 problems) Due: Wed., 09/23/2020 for both Sessions 002 and 003. Write C code that does the following: 1. Interactively read the three coefficients of a quadratic equation and compute the two roots. The program must alert if there is no real root, i.e. read a, b, c of a x2 + b x + c = 0, and compute Note: sqrt is available in math.h. You need to compile the program with "-lm" option, i.e. gcc -lm myprogram.c Make sure that you add a routine to check the positiveness of the discriminant using the if statement. Show actual runs and examples. 2. Interactively read temperature in Celsius and convert it to Fahrenheit. Note C = (F -32 ) × 5/9 . Example: $ a.out Enter temperature in C = 29 It is 84.2 degrees in Fahrenheit. 3. Write a C program to sum up the first 100, 1000, and then 10000 terms of the series, respectively, to see whether the sum is getting closer to Note that the general term, an, is expressed as See below for the background of this series. 2 4. Write a C program to sum up the first 100, 1000, and then 10000 terms of the series, respectively, to see what value it may approach. 5. A sequence an is given with the following rule: an+2 = - 2 an+1 + 3 an, a0 = 2, a1 = -1. Write a C program to compute a17. 3 6. Write a C code to make a table of (x , x - x3/6 + x5/120, sin x) using functions in the format of x x - x3/6 + x5/120 sin (x) 0.0 2.000 1.000 0.1 1.901 1.105 0.2 1.808 1.221 ... ... ... 2.0 8.000 7.389 Note: The values above are not correct. Template #include float f(float x) { return x*x ; } /* main */ int main() { int i; printf(" x f(x) \n"); printf("-----------------\n"); for (i=0; i< 10;="" i++)="" printf(="" "="" (fill="" in="" your="" code)="" \n",="" 0.1*i,="" f(0.1*i));="" return="" 0;="" }="" 7.="" (a)="" write="" a="" function,="" int="" factorial(int="" n),="" which="" returns="" n!="" (the="" factorial="" of="" n,="" i.e.="" 1="" ×2="" ×3="" ×...×n.)="" (b)="" using="" int="" factorial(int="" n)="" above,="" write="" a="" program="" to="" compute="" 4="" 8.="" we="" want="" to="" find="" one="" of="" the="" roots="" of="" a="" cubic="" equation="" given="" by="" x3="" +="" x="" -="" 1="0" which="" is="" between="" 0="" and="" 1="" by="" an="" iterative="" method.="" modify="" the="" equation="" above="" to="" start="" with="" an="" appropriate="" initial="" value="" and="" do="" the="" iteration="" above="" until="" it="" is="" convergent.="" for="" example,="" the="" simplest="" (minimum)="" code="" may="" look="" like:="" #include=""> int main() { int i; float x; printf("Enter initial guess =");scanf("%f",&x); for (i=0;i<100;i++) /* insert your iteration code */ printf("%f\n",x); return 0; } 9. a set of 10 float numbers is given below. write a c program to show how many out of 10 are between 2.0 and 10.0 (including these two values). {1.0, 9.0, 13.0, 8.5, 3.0, 9.0, 17.0, 4.5, 10.0, 2.0} =0.728… 5 instruction for submission • go on canvas, select course mae 2360-002 or 003 (depending on which lab session that you are enrolled in), then click on assignments and select the respective hw or lab assignment to be submitted and upload the document. • the format in which the assignment is to be submitted is only docx and doc. • the time period given for the submission is the day that the assignment is given till the mid-night of due date. • it will be a late submission only until one day after due date. the late submission will lose 20% of the score. if someone delays beyond this, the link for submission of the assignment will disappear and will be considered as “not submitted”. • two attempts will be allowed for the submission of the respective assignment. • please do not copy others works, plagiarism check will be deployed to catch such an activity. template for hw 1. hw 01 mm/dd/year (submission date) section 002 (or 3) doe, john (last name, first name) 1325 (last 4 digits of your student id) problem 1 • program listing • example run • discussion (optional) problem 2 problem 3 *="" insert="" your="" iteration="" code="" */="" printf("%f\n",x);="" return="" 0;="" }="" 9.="" a="" set="" of="" 10="" float="" numbers="" is="" given="" below.="" write="" a="" c="" program="" to="" show="" how="" many="" out="" of="" 10="" are="" between="" 2.0="" and="" 10.0="" (including="" these="" two="" values).="" {1.0,="" 9.0,="" 13.0,="" 8.5,="" 3.0,="" 9.0,="" 17.0,="" 4.5,="" 10.0,="" 2.0}="0.728…" 5="" instruction="" for="" submission="" •="" go="" on="" canvas,="" select="" course="" mae="" 2360-002="" or="" 003="" (depending="" on="" which="" lab="" session="" that="" you="" are="" enrolled="" in),="" then="" click="" on="" assignments="" and="" select="" the="" respective="" hw="" or="" lab="" assignment="" to="" be="" submitted="" and="" upload="" the="" document.="" •="" the="" format="" in="" which="" the="" assignment="" is="" to="" be="" submitted="" is="" only="" docx="" and="" doc.="" •="" the="" time="" period="" given="" for="" the="" submission="" is="" the="" day="" that="" the="" assignment="" is="" given="" till="" the="" mid-night="" of="" due="" date.="" •="" it="" will="" be="" a="" late="" submission="" only="" until="" one="" day="" after="" due="" date.="" the="" late="" submission="" will="" lose="" 20%="" of="" the="" score.="" if="" someone="" delays="" beyond="" this,="" the="" link="" for="" submission="" of="" the="" assignment="" will="" disappear="" and="" will="" be="" considered="" as="" “not="" submitted”.="" •="" two="" attempts="" will="" be="" allowed="" for="" the="" submission="" of="" the="" respective="" assignment.="" •="" please="" do="" not="" copy="" others="" works,="" plagiarism="" check="" will="" be="" deployed="" to="" catch="" such="" an="" activity.="" template="" for="" hw="" 1.="" hw="" 01="" mm/dd/year="" (submission="" date)="" section="" 002="" (or="" 3)="" doe,="" john="" (last="" name,="" first="" name)="" 1325="" (last="" 4="" digits="" of="" your="" student="" id)="" problem="" 1="" •="" program="" listing="" •="" example="" run="" •="" discussion="" (optional)="" problem="" 2="" problem="">
Answered Same DaySep 21, 2021

Answer To: 1 HW #1 Assignment (9 problems) Due: Wed., 09/23/2020 for both Sessions 002 and 003. Write C code...

Arun Shankar answered on Sep 23 2021
131 Votes
1.
#include
#include
int main(void)
{
float a, b, c;
printf("Enter a: ");

scanf("%f",&a);
printf("Enter b: ");
scanf("%f",&b);
printf("Enter c: ");
scanf("%f",&c);
if(a==0)
{
printf("\n a cannot be zero!");
return 0;
}
float disc = (b * b) - (4 * a * c);
if(disc < 0)
printf("\nNo real roots");
else if(disc == 0)
printf("\nOnly one real root: %f", (-b) / (2 * a));
else
{
float root1 = ((-b) + (sqrt(disc))) / (2 * a);
float root2 = ((-b) - (sqrt(disc))) / (2 * a);
printf("\nTwo real roots: %f and %f", root1, root2);
}

return 0;
}
2.
#include
int main(void)
{
float celcius, fahrenheit;
printf("Enter temperature in celcius: ");
scanf("%f",&celcius);
fahrenheit = 32.0 + ((9.0/5.0) * celcius);
printf("\nTemperature = %.2f F", fahrenheit);
return 0;
}
3.
#include
#define PI 3.141592653589793238
int...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here