Академический Документы
Профессиональный Документы
Культура Документы
Submitted by:
Te, Royce T.
Submitted to:
I.
Learning Objectives:
-
II.
Introduction
This laboratory exercise will focus mostly on the use of engineering formulas and equations, that will
be integrated to a C program. The equations that will be included in this lab report will be mostly from
Analytic Geometry, with the focus on graphical equations that include x, y coordinates and the slope as
the variables for the equations. The reason for the choice of the equations is due to the significance of
graphical analysis for multiple courses in the College of Engineering. The use of this program will be
very applicable in most courses that require graphical analysis or any form of plotting in a coordinates
system.
Some of the formulas and equations that will be present in the code will be for solving the variables
of lines and parabolas, since these are mostly the common graphical formations that are present.
IV. Flowchart
V.
Source Code
#include <stdio.h>
#include <stdlib.h>
int main()
{
int menu,syntax;
printf("\n\tFormulas and Equations\n");
printf("\tPlease Input Your Choice\n");
printf("\t 1.) Lines\n");
printf("\t 2.) Parabolas\n");
printf("\t 3.) Exit\n");
scanf("%d", &menu);
if (menu==1)
{
int syntax;
printf("\n\tLine Variables\n");
printf("\t 1.) Slope\n");
printf("\t 2.) Y-Intercept\n");
printf("\t 3.) X-coordinate\n");
printf("\t 4.) Y-coordinate\n");
printf("\t 5.) Exit\n");
scanf("%d", &syntax);
if (syntax==1)
{
float a,b,c,d;
printf("\t Please input the x,y,y-intercept in order\n");
scanf("%d %d %d",&c,&a,&b);
d=(a-b)/c;
printf("\t The slope is %5.2f\n",d);
return main();
}
if (syntax==2)
{
float a,b,c,d;
printf("\t Please input the x,y,slope in order\n");
scanf("%d %d %d",&c,&a,&b);
d=a-b*c;
printf("\t The y-intercept is %5.2f\n",d);
return main();
}
if (syntax==3)
{
float a,b,c,d;
printf("\t Please input the slope,y,y-intercept in order\n");
scanf("%d %d %d",&c,&a,&b);
d=(a-b)/c;
printf("\t The x-coordinate is %5.2f\n",d);
return main();
}
if (syntax==4)
{
float a,b,c,d;
printf("\t Please input the x,slope,y-intercept in order\n");
scanf("%d %d %d",&c,&a,&b);
d=c*a+b;
printf("\t The y-coordinate is %5.2f\n",d);
return 0;
}
if (syntax==5)
return main();
}
if (menu==2)
{
int syntax;
printf("\n\tParabola Variables\n");
printf("\t 1.) Vertex\n");
printf("\t 2.) X-coordinate\n");
printf("\t 3.) Y-coordinate\n");
printf("\t 4.) Exit\n");
scanf("%d", &syntax);
if(syntax==1)
{
float a,c,d,f;
printf("\t Please input the value of b, the value of a\n");
scanf("%d %d",&c,&a);
d=c/(2*a);
f=(d*c)-(d*a);
printf("\t The x coordinate vertex is %5.2f\n",d);
printf("\t The y coordinate vertex is %5.2f\n",f);
return main();
}
if(syntax==2)
{
int a,b,c;
float d;
printf("\t Please input the vertex,y-coordinate in order\n");
scanf("%d %d %d",&c,&a,&b);
d=(c-a)^2-b;
printf("\t The x-coordinate is %5.2f\n",d);
return main();
}
if(syntax==3)
{
int a,b,c;
float d;
printf("\t Please input the vertex,x-coordinate in order\n");
scanf("%d %d %d",&c,&a,&b);
d=(b+c)^2-a;
printf("\t The y-coordintate is %5.2f\n",d);
return main();
}
if(syntax==4)
{
return main();
}
}
if (menu==3)
{
printf("\n\tClosing program\n");
return 0;
}
return main();
}
VIII. Conclusion
This lab experiment proved to be challenging but doable with the functions that were available
for use, although more complex functions and operations could not be used in the equations due
to the complexity of the coding needed. All problems encountered with the code like the
rounding wrong, syntax were all resolved with internet resources and past lab manuals from the
prerequisites of the course.