0% found this document useful (0 votes)
13 views

Midterm

The document discusses solving systems of linear equations and quadratic equations. It provides code snippets in C programming language to solve up to 3 equations simultaneously and to find the roots of a quadratic equation. The document covers different approaches depending on the number of equations or whether the quadratic equation has real, repeated, or complex roots.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Midterm

The document discusses solving systems of linear equations and quadratic equations. It provides code snippets in C programming language to solve up to 3 equations simultaneously and to find the roots of a quadratic equation. The document covers different approaches depending on the number of equations or whether the quadratic equation has real, repeated, or complex roots.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

COMPUTER AIDED

CS 520A

ASSIGNMENT
STIFFNESS MATRIX STRUCTURAL ANALYSISI FOR TRUSSES

SUBMITTED BY:
GONZALES,JOHN CARLO B.

SUBMITTED TO:
ENGR. LEONARDO V SURIO
EQUATION SOLVER

#include<stdio.h> printf("\n ENTER THE NUMBER OF EQUATION YOU


WANT TO SOLVE:");
#include<conio.h>
scanf("%f",&Choice);
float
x1,x2,x3,y1,y2,y3,z1,z2,z3,X,Y,Z,D,x,y,z,Choice,e1,e2,e3 if( Choice == 3){
,c1,c2,c3;
printf ("\n Enter X1:");
main()
sca
{

nf("%f",&x1); printf ("\n Enter Z3:");

printf ("\n Enter Y1:"); scanf("%f",&z3);

scanf("%f",&y1); printf ("\n Enter CONSTANT 3:");

printf ("\n Enter Z1:"); scanf("%f",&c3);

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;

printf ("\n Enter Y2:"); Z= ((x1*y2*c3)+(y1*c2*x3)+(c1*x2*y3))-


((x3*y2*c1)+(y3*c2*x1)+(c3*x2*y1))/D;
scanf("%f",&y2);
printf("\nThe Determinants are:");
printf ("\n Enter Z2:");
printf("\nx = %f",X);
scanf("%f",&z2);
printf("\ny = %f",Y);
printf ("\n Enter CONSTANT 2:");
printf("\nz = %f",Z);
scanf("%f",&c2);
}
printf ("\n Enter X3:");
else if (Choice ==2){
scanf("%f",&x3);
printf ("\n Enter X1:");
printf ("\n Enter Y3:");
scanf("%f",&x1);
scanf("%f",&y3);
printf ("\n Enter Y1:");
scanf("%f",&y1); Y =((x1*c2)-(x2*c1))/D;

printf ("\n Enter CONSTANT 1:"); printf("\nThe Determinatants are:");

scanf("%f",&c1); printf("\nx = %f",X);

printf ("\n Enter X2:"); printf("\ny = %f",Y);

scanf("%f",&x2); }

printf ("\n Enter Y2:"); else{

scanf("%f",&y2); printf("\nWrong Choice");

printf ("\n Enter CONSTANT 2 :"); }

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<conio.h> else if (CHOICE ==2){

#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",&b); printf("\n Area of Square");

printf("\nnter the triangle height:"); printf("\nEnter The side of the Square:");

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;

else if (CHOICE == 4){ printf("\nThe Area of the Rectangle is %f sq.


units",A);

}
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____________________________________________
________________________________"); }

printf("\nThe area the the trapezoid is %dsq.


units",At);
else { printf("\
} n____________________________________________
________________________________");
else if (CHOICE == 5){
printf ("\n Enter only . Please try Again
printf("\
Thankyou!!!!");
n____________________________________________
________________________________"); }

printf("\n Area of Rectangle");

printf("\nEnter The Base of the Rectangle:"); scanf("%d");

scanf("%f",&s1); return 0;

printf("\nEnter The Height of the Rectangle:"); }

scanf("%f",&s2);

You might also like