Write a complete C++ program, including at least one good commen t, to do the fo
ID: 3683073 • Letter: W
Question
Write a complete C++ program, including at least one good commen
t, to do the
following: Your program will compute values of a formula that exp
resses y in terms of x.
The formula is:
4x
3
+
8x
2
- 31x - 35
y =
--
----------------------------------
(
10
x
2
+ 1)
1/2
+ 7 * | x + 2.5 |
| | means absolute value);(...)
1/2
means square root use library functions for these
1. The program should start by printing a message giving you
r name and saying this is
the output of your second program.
2. Then it should evaluate the formula starting with x = -5 (ne
gative 5), going up by 0.5
each time until it reaches 4.0. Therefore, it will use these values for x
:-5
,
-4.5, ...,-0.5, 0,
0.5, 1, ..., 3.0, 3.5, 4.0.
For each x value, the program should compute the correspond
ing y value. It should
print these values together with explanations of what the valu
es represent. For
example, it could print the string "X = ", then the value of x, the strin
g "Y = ", the value of
y, and a message. (It is also possible to use column headings and
have your numbers
underneath the headings.)
The message should say one of three things:
If the value of y is exactly 0, the message should say Y IS ZERO.
If the value is positive, the message should say Y IS POSITIVE.
If the value is negative, the message should say Y IS NEGATIVE.
A
typical line of output would look like this (or the values of x
and y can appear
underneath column headings):
X = -2 Y = 0 Y IS ZERO (actually, this one will not be zero)
3. Once you have finished using x = 4.0, the program should
print a message
(underneath the last line of output) saying that your first program i
s complete, then stop.
Write a complete C++ program, including at least one good comment, to do the following: Your program will compute values of a formula that expresses y in terms of x. The formula is 4x+8x2-31x 35 (10x2 1)12 7|x 2.5 I I means absolute value).(..)12 means square root use library functions for these 1. The program should start by printing a message giving your name and saying this is the output of your second program. 2. Then it should evaluate the formula starting with x =-5 (negative 5), going up by 0.5 each time until it reaches 4.0. Therefore, it will use these values for x-5, -4.5, ....-0.5, 0 0.5, 1,.. 3.0, 3.5,4.0 For each x value, the program should compute the corresponding y value. It should print these values together with explanations of what the values represent. For example, it could print the string X", then the value of x, the string "Y", the value of y, and a message. (It is also possible to use column headings and have your numbers underneath the headings.) The message should say one of three things If the value of y is exactly 0, the message should say Y IS ZERO If the value is positive, the message should say Y IS POSITIVE. If the value is negative, the message should say Y IS NEGATIVE. A tvpical line of output would look like this (or the values of x and y can appear underneath column headings): X =-2 Y = 0 Y IS ZERO (actually, this one will not be zero) 3. Once you have finished using x = 4.0, the program should print a message (underneath the last line of output) saying that your first program is complete, then stop.Explanation / Answer
#include<stdio.h>
#include<iostream.h>
int main(){
int x=0;
//variable declration
printf("Enter x value:");
float opt=0;
scanf("%d",&x);
if(x1=0);
opt=returnYvalue(x);
}
printf("output is:" opt);
float returnYvalue(int x){
return 4x3+8x2-3x-35/((10x2+1)1/2 +7*|x+2.5|)
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.