Midterm
Midterm
CS 520A
ASSIGNMENT
STIFFNESS MATRIX STRUCTURAL ANALYSISI FOR TRUSSES
SUBMITTED BY:
GONZALES,JOHN CARLO B.
SUBMITTED TO:
ENGR. LEONARDO V SURIO
EQUATION SOLVER
scanf("%f",&z1); D = (((x1*y2*z3)+(y1*z2*x3)+(z1*x2*y3)))-
(((x3*y2*z1)+(y3*z2*x1)+(z3*x2*y1)));
printf ("\n Enter CONSTANT 1:");
X= ((c1*y2*z3)+(y1*z2*c3)+(z1*c2*y3))-
scanf("%f",&c1);
((c3*y2*z1)+(y3*z2*c1)+(z3*c2*y1))/D;
printf ("\n Enter X2:");
Y= ((x1*c2*z3)+(c1*z2*x3)+(z1*x2*c3))-
scanf("%f",&x2); ((x3*c2*z1)+(c3*z2*x1)+(z3*x2*c1))/D;
scanf("%f",&x2); }
scanf("%f",&c2); scanf("%d");
D = (x1*y2)-(x2*y1); return 0;
X = ((c1*y2)-(c2*y1))/D; }
#include<stdio.h> }
#include<conio.h> else if (discriminant==0){
#include<math.h> x1 = (-b+sqrt(discriminant))/(2*a);
float a,b,c,discriminant,realPart,imaginaryPart,over,x1,x2; printf("\n x1=x2=%f",&x1);}
main() else{
{ realPart=-b/(2*a);
printf("Enter Ax:"); imaginaryPart=(-discriminant);
scanf("%f",&a); over=(2*a);
printf("\nEnter By:"); printf("\nx1=%f+(squareroot of
scanf("%f",&b); %f)/%f",realPart,imaginaryPart,over);
printf("\nEnter C:"); printf("\nx2=%f-(squareroot of
scanf("%f",&c); %f)/%f",realPart,imaginaryPart,over);
discriminant=b*b-4*a*c; }
if (discriminant>0){ scanf("%d");
x1=(-b+sqrt(discriminant))/(2*a); return 0;
x2=(-b-sqrt(discriminant))/(2*a); }
printf("\n x1 =%f",x1);
printf("\n x2 =%f",x2);
#include<stdio.h> }
#include<math.h> printf("\
n____________________________________________
float b,h,s1,s2,s3,A,choice,x,CHOICE; ________________________________");
int b1,b2,w,At; printf("\nCIRCLE");
main(){ printf("\
printf(" 1. Area of triangle 2 Area of circle 3. Area of n____________________________________________
Square " ); ________________________________");
printf(" \n4. Area of Trapezoid 5.Area of Rectangle printf("\n Area of Circle Given its Radius");
6. Ellipse " ); printf("\n Enter the Radius of the circle:");
scanf("%f",&s1);
printf("\n Enter your choice:"); A
scanf("%f",&CHOICE); =3.1415926535897932384626433832795*s1*s1 ;
if (CHOICE==1) { printf("\
n____________________________________________
printf("\ ________________________________");
n____________________________________________
________________________________"); printf("\n The Area of the circle with radius
%f is %fsq units",s1,A);
printf("\nTRIANGLE");
printf("\
n____________________________________________ }
________________________________"); else if (CHOICE == 3){
printf("\nGiven Base and Height Of the printf("\
Triangle"); n____________________________________________
printf("\nEnter triangle base:"); ________________________________");
scanf("%f",&h); scanf("%f",&s1);
A =(b*h)/2; A= s1*s1;
printf("\n Area of the triangle is %fsq. printf("\nThe Area of the Square is %fsq. units",A);
units",A); }
A= s1*s2;
}
printf("\
n____________________________________________ else if (CHOICE == 6){
________________________________");
printf("\
printf("\n Area of Trapezoid"); n____________________________________________
________________________________");
printf("\n Enter the height of the trapezoid:");
printf("\n Area of Ellipse");
scanf("%d",&w);
printf("\nEnter A:");
printf("\n Enter your 1st base :");
scanf("%f",&s1);
scanf("%d",&b1);
printf("\nEnter B");
printf("\n Enter your 2nd base :");
scanf("%f",&s2);
scanf("%d",&b2);
A=
At= w*((b1+b2)/2);
(3.1415926535897932384626433832795)*(s1*s2);
printf("\
printf("\nThe Area of the Ellipse is %f sq. units",A);
n____________________________________________
________________________________"); }
scanf("%f",&s1); return 0;
scanf("%f",&s2);