The C Compiler Being used is Visual Studio 2015 if possible could the program be
ID: 3733576 • Letter: T
Question
The C Compiler Being used is Visual Studio 2015 if possible could the program be run on that
Problem Statement: A person, hi (m) tall, attempts to throw a rock through a hole in the ground that is L (m) away (see figure below). The hole is w (m) wide. The rock is thrown with an initial velocity vo, and an angle of inclination (Note that090°). Vo hi , At some time t after the rock was thrown, the horizontal distance it has travelled, d, is given by d = (vo cos )t and the height of the rock, h, is given byExplanation / Answer
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define g 9.08
void main()
{
clrscr();
float h1,w,L,v0,ang,da,b,c,det,root1,root2,df;
printf("Enter h1"); // Enter height of person in meters
scanf("%f",&h1);
printf("Enter w "); //Enter width of the hole in meters
scanf("%f",&w);
printf("Enter L"); //Enter the distance of person from hole in meters
scanf("%f",&L);
printf("Enter v0"); //
scanf("%f",&v0);
printf("Enter ang"); //Enter angle between 0 and 90 degrees
scanf("%f",&ang);
b=v0*sin(ang);
a=(-1/2)*g;
c=h1;
d=v0*cos(ang)*t;
det= (b*b)-(4*a*c);
if(det < 0){
printf("Roots are complex number. ");
printf("Roots of quadratic equation are: ");
printf("%.3f%+.3fi",-b/(2*a),sqrt(-d)/(2*a));
printf(", %.3f%+.3fi",-b/(2*a),-sqrt(-d)/(2*a));
}
else if(det==0){
printf("Both roots are equal. ");
root1 = -b /(2* a);
printf("Root of quadratic equation is: %.3f ",root1);
}
else{
printf("Roots are real numbers. ");
root1 = ( -b + sqrt(d)) / (2* a);
root2 = ( -b - sqrt(d)) / (2* a);
printf("Roots of quadratic equation are: %.3f , %.3f",root1,root2);
}
}
if(root1>0)
{r=root1;
}
else if(root2>0)
{
r=root2;
}
df=v0*cos(ang)*root1;
printf("%f , %f",root1,df);
if(d<(L+w) && d>L)
{
printf("Successful");
}
else
{
printf("Unsuccessful");
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.