Given: f(x) =-2x6-1.5x4 + 10x + 2 Use a root location technique to determine the
ID: 3281553 • Letter: G
Question
Given: f(x) =-2x6-1.5x4 + 10x + 2 Use a root location technique to determine the maximum of this function. Perform iterations until the approximate relative error falls below 5%. If you use a bracketing method, use initial guesses of xi 0 and xu. If you use the Newton-Raphson, use an initial guess of xi 1. If you use the secant method, use an initial guesses of xi-1 0 and Xi. Assuming that convergence is not an issue, choose the technique that is best suited to this problem. Justify your choice.Explanation / Answer
ANSWER:
#include <stdio.h>
struct student
{
char name[50];
int Age;
char Country_Name[20];
char City_Name[20];
float Height;
float Weight;
char Education[20];
} s[8];
void getAverage(float,float);
void Increase(float,float);
int main()
{
int i;
printf("Enter information of students: ");
for(i=0; i<8; ++i)
{
printf("Enter name: ");
scanf("%s",s[i].name);
printf("Enter Age: ");
scanf("%d",&s[i].Age);
printf("Enter Country Name: ");
scanf("%s",s[i].Country_Name);
printf("Enter the City Name: ");
scanf("%s",s[i].City_Name);
printf("Enter the Height: ");
scanf("%f",&s[i].Height);
printf("Enter the Weight: ");
scanf("%f",&s[i].Weight);
printf("Enter the education : ");
scanf("%s",s[i].Education);
printf(" ");
}
printf("Displaying Information: ");
for(i=0; i<8; ++i)
{
printf("Name: ");
puts(s[i].name);
printf("Age: %d ",s[i].Age);
printf("Country Name: ");
puts(s[i].Country_Name);
printf("City Name: ");
puts(s[i].City_Name);
printf("Height: %.1f ",s[i].Height);
printf("Weight: %.1f ",s[i].Weight);
printf("Education: ");
puts(s[i].Education);
printf(" ");
}
getAverage(s[i].Height,s[i].Weight);
Increase(s[0].Height,s[0].Weight);
return 0;
}
void getAverage(float x,float y)
{
int i,total=0,sum=0;
for(i=0;i<8;i++)
{
total += s[i].Weight;
x = total/8;
sum += s[i].Height;
y = sum/8;
}
printf("The average Weight is %.2f ",x);
printf("The average Height is %.2f ",y);
}
void Increase(float x1,float y1)
{
x1 =(s[0].Weight/5)+(s[0].Weight);
y1 =(s[0].Height/5)+(s[0].Height);
printf("The new weight of person 1: %.2f ",x1);
printf("The new height of person 1: %.2f",y1);
}
please rate it thanks
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.