civil engineering computer programming sessional

Post on 12-Aug-2020

11 Views

Category:

Education

8 Downloads

Preview:

Click to see full reader

DESCRIPTION

Civil Engineering Computer Programming Sessional. This is the soft file of C programming Project which includes some example of Programming, that help you to understand the basic root of Programming in Civil Engineering.

TRANSCRIPT

Civil Engineering Computer programming Sessional

CIE 206

Mr.Kundan ID. 1507365 LEVEL 2 SEMESTER II Civil Engineering HSTU, Bangladesh

INDEX

Progra

m No.

Name of The Program Page

No.

1. To find out the largest among 3 numbers. 02

2. To find out grade from marks.

03

3. To Calculate for maximum bending moment and shear force for the simple supported structure.

05

4. To calculate shear force and bending moment at any point of given structure.

06

5. To calculate of income tax for govt. officials having his /her salary as the only source of income.

08

6. To find out maximum spacing of floor beams for a slab system.

11

7. To find out materials required for concrete mix. 12

8. To find the summation of series 1

𝐿3+

1

𝐿5+

1

𝐿7+

1

𝐿9 …… up to

100 terms.

14

9. To read and write a matrix using Array.

15

10. To find the solution of Interpolation problem up to 4 data.

17

11. To find the multiplication of two matrices. 19

12. To find the inverse of matrix. 21

13. To solve a system of equations for 3 unknowns. 24

14. To show a tabular result of RL at different points. 26

15. To calculate shear force, bending moment, shear stress and bending stress at anywhere of the given beam.

27

16. To calculate shear force, bending moment, shear stress and bending stress at anywhere of the given cantilever beam.

30

17. To calculate stress in a member due to change in temperature.

32

18. Unit conversion of Pressure, Load and Volume. 33

19. To calculate bar length for circular foundation. 35

20. To calculate bar length for triangular slab. 36

/* Program No. : 01

Name of The Program: To find out the largest among 3 numbers. Programmed By: KUNDAN YADAV Student ID: 1507365 */ #include<stdio.h> #include<conio.h> void main() { int a,b,c; clrscr(); printf("Enter the 3 values separated by space\n"); scanf("%d%d%d",&a, &b, &c); if(a>b && a>c) { printf("\n\nThe largest value among given numbers is %d",a); } if(b>a && b>c) { printf("The largest value among given numbers is %d",b); } else { printf("The largest value among given numbers is %d",c): printf(“\n\n….Pressing any key makes you exit…”); } getch(); } Input: Enter the 3 values separated by space 5 2 8 Press Enter. Output: The largest value among given numbers is 8 ….Pressing any key makes you exit…

/* Program No. : 02 Name Of The Program: To find out grade from marks. Programmed By: KUNDAN YADAV Student ID : 1507365 */ #include <stdio.h> #include <conio.h> void main() { float MARK; char* GRADE; clrscr(); printf("Input marks:"); scanf("%f", &MARK); if(MARK<40) GRADE="F ::::::Sorry!!!"; if(MARK>=40 &&MARK<45) GRADE="D :::::::Congratulations!!!"; if(MARK>=45 &&MARK<50) GRADE="C :::::::Congratulations!!!"; if(MARK>=50 &&MARK<55) GRADE="C+ :::::::Congratulations!!!"; if(MARK>=55 &&MARK<60) GRADE="B- :::::::Congratulations!!!"; if(MARK>=60 &&MARK<65) GRADE="B :::::::Congratulations!!!"; if(MARK>=65 &&MARK<70) GRADE="B+ Good:::::::Congratulations!!!"; if(MARK>=70 &&MARK<75) GRADE="A- Very Good:::::::Congratulations!!!"; if(MARK>=75 &&MARK<80) GRADE="A Welldone:::::::Congratulations!!!";

if(MARK>=80) GRADE="A+ Excellent:::::::Congratulations!!!"; printf("Your Grade is %s ",GRADE); printf(“\n\n….Pressing any key makes you exit…”); getch(); } Input: Input marks: 49 Press Enter Output: Your Grade is C :::::::Congratulations!!! ….Pressing any key makes you exit…

/* Program No. : 03 Name of The Program: To calculate for maximum bending moment and shear force for the simple supported structure. Programmed By: KUNDAN YADAV Student ID: 1507365 */ #include <stdio.h> #include <conio.h> #include <math.h> void main() { float L,W,V,M; clrscr(); printf("Enter the value of span (in Meter):"); scanf(" %f",&L); printf("Enter the value of load (in KN/m):"); scanf(" %f",&W); V=W*(L/2); M=(W*pow(L,2))/8; printf("Maximum shear force is %.2f KN\nMaximum bending moment is %.2f KN-m",V,M); printf(“\n\n….Pressing any key makes you exit…”); getch(); } Input: Enter the value of span ( in Meter):3 Enter the value of load ( in KN/m):2 Press enter Output: Maximum shear force is 3.00 KN Maximum bending moment is 2.25 KN-m ….Pressing any key makes you exit…

/* Program No. : 04 Name of The Program: To calculate shear force and bending moment at any point of given structure. Programmed By: KUNDAN YADAV Student ID : 1507365 */ #include <stdio.h> #include <conio.h> #include <math.h> #define M 17 #define R 9 void main() { float x,Vx,Mx; clrscr(); printf("Enter the distance (in m) at which shear force and bending moment is required:\n(from left to right) \n"); scanf(" %f",&x); if(x>=0 && x<=2) { Vx=R-3*x; Mx=(R*x)-M-(3*pow(x,2)/2); } if(x>2 && x<=3) { Vx=R-6; Mx=(R*x)-M-6*(x-1); } if(x>3 && x<=5) { Vx=R-8; Mx=(R*x)-M-6*(x-1)-2*(x-3); } printf("Shear force is %.2f KN\nMaximum bending moment is %.2f KN-m at distance %f from left.",Vx,Mx,x); printf(“\n\n….Pressing any key makes you exit…”); getch(); } Input: Enter the distance (in m) at which shear force and bending moment is required: (from left to right) 3.5 Press enter

Output: Shear force is 1.00 KN Maximum bending moment is -1.50 KN-m at distance 3.500000 from left. ….Pressing any key makes you exit…

/* Program No. : 05 Name of The Program: To calculate of income tax for govt. officials having

his /her salary as the only source of income.

Programmed By: KUNDAN YADAV Student ID: 1507365 */ #include<stdio.h> #include<conio.h> #include<math.h> void main() { char SEX,AREA; float BASIC,S1,S2,S3,S4,S5,MINI,TAXABLE_INCOME,TAX,MAX_INVESTMENT,INVEST,ACTUAL_TAX; clrscr(); start1: printf("Specify your Gender. Press 'M' for Male or press 'F' for Female\n:::"); scanf(" %c", & SEX); if(SEX !='M' &&SEX!='m' &&SEX!='f' &&SEX!='F') { printf("Your Input is Wrong, Please!!! Try Again!!!"); goto start1; } start2: printf("Mention your Location:\nFor Dhaka/Chittagong city corporation, Press '1'\nFor other city corporation, Press '2' and\nFor local area, Press '3'\n:::"); scanf(" %c", &AREA); if(AREA!='1' &&AREA!='2' &&AREA!='3') { printf("Input Wrong, Please!!! Try Again!!!"); goto start2; } printf("Input your basic salary(in BDT):\n:::"); scanf(" %f", &BASIC); if(SEX=='M'||SEX=='m') { S1=250000; } if(SEX=='F'||SEX=='f') { S1=300000; } S2=S1+400000; S3=S2+500000;

S4=S3+600000; S5=S4+3000000; if(AREA=='1') { MINI=5000; } if(AREA=='2') { MINI=4000; } if(AREA=='3') { MINI=3000; } TAXABLE_INCOME=BASIC*14.2; if(TAXABLE_INCOME<=S1) { TAX=MINI; } if(TAXABLE_INCOME>S1 && TAXABLE_INCOME <=S2) { TAX=(TAXABLE_INCOME-S1)*0.1; } else if(TAXABLE_INCOME>S2 && TAXABLE_INCOME <=S3) { TAX=(TAXABLE_INCOME-S2)*0.15+(S2-S1)*0.1; } else if(TAXABLE_INCOME>S3 && TAXABLE_INCOME <=S4) { TAX=(TAXABLE_INCOME-S3)*0.2+(S3-S2)*0.15+(S2-S1)*0.1; } else if(TAXABLE_INCOME>S4 && TAXABLE_INCOME <=S5) { TAX=(TAXABLE_INCOME-S4)*0.25+(S4-S3)*0.2+(S3-S2)*0.15+(S2-S1)*0.1; } if(TAXABLE_INCOME>S5) { TAX=(TAXABLE_INCOME-S5)*0.3+(S5-S4)*0.25+(S4-S3)*0.2+(S3-S2)*0.15+(S2-S1)*0.1; } MAX_INVESTMENT=TAXABLE_INCOME*0.3; printf("You can invest maximumn upto %.2f BDT.\nHow much did you invest?:\n:::",MAX_INVESTMENT); scanf("%f", &INVEST); if(INVEST>MAX_INVESTMENT) { INVEST=MAX_INVESTMENT;

} ACTUAL_TAX=TAX-INVEST*0.15; if(ACTUAL_TAX<MINI) { ACTUAL_TAX=MINI; } printf("You have to pay %.2f BDT as Income Tax.\n\n\n\n.................Have a Good Day.............",ACTUAL_TAX); printf(“\n\n….Pressing any key makes you exit…”); getch(); } Input: Specify your Gender. Press ‘M’ for Male or press ‘F’ for Female :::f Mention your Location: For Dhaka/Chittagong city corporation, Press ‘1’ For other city corporation, Press ‘2’ and For local area, Press ‘3’ :::2 Input your salary (in BDT): :::38000 You can invest maximum upto 161880.00 BDT. How much did you invest?: :::80000 Output: You have to pay 11960.00 BDT as Income Tax. .................Have a Good Day............. ….Pressing any key makes you exit… /* Program No. : 06

Name of The Program: To find out maximum spacing of floor beams for a slab system. Programmed By: KUNDAN YADAV Student ID: 1507365 */ #include <stdio.h> #include <conio.h> #include <math.h> void main() { float SPAN,LOAD,DEPTH,WIDTH,STRENGTH, SPACING,SPACING_M; clrscr(); printf("Span of floor beam (in m):\n"); scanf(" %f", &SPAN); printf("Load (in MPa):\n"); scanf(" %f",&LOAD); printf("Enter Beam depth and width respectively spareted by space (in mm):\n"); scanf(" %f %f",&DEPTH,&WIDTH); printf("Strength (in MPa):\n"); scanf(" %f", &STRENGTH); SPACING=(4*STRENGTH*WIDTH*pow(DEPTH,2))/(3*LOAD*pow(SPAN,2)*1000*1000); SPACING_M=SPACING/1000; printf("Spacing= %.2f meter", SPACING_M); getch(); } Input: Output: /* Program No. : 07

Name of The Program: To find out materials required for concrete mix. Programmed By: KUNDAN YADAV Student ID: 1507365 */ #include<stdio.h> #include<conio.h> #include<math.h> void main() { float WET_VOLUME,DRY_VOLUME,C,FA,CA,CEMENT,WATER,WC_RATIO, AMT_WATER; char RATIO; clrscr(); printf("Enter the required wet volume of Concrete (in cu ft.):\n"); scanf(" %f",&WET_VOLUME); start: printf("Mention the Mixing Ratio:\nPress 1 for Ratio 1:2:4\nPress 2 for Ratio 1:3:6 and\nPress 3 for Ratio 1:1.5:3\n::"); scanf(" %c",&RATIO); if(RATIO !='1' &&RATIO!='2' &&RATIO!='3') { printf("Your Input is Wrong, Please!!! Try Again!!!"); goto start; } DRY_VOLUME=WET_VOLUME*1.5; if(RATIO=='1') { C=DRY_VOLUME/7; FA=C*2; CA=C*4; } if(RATIO=='2') { C=DRY_VOLUME/10; FA=C*3; CA=C*6; } if(RATIO=='3') { C=DRY_VOLUME/5.5; FA=C*1.5; CA=C*3; } CEMENT=C/1.25; WATER=(C*.3)+((FA+CA)*.05); WC_RATIO=WATER/C;

AMT_WATER=(WC_RATIO*112)/10; printf("Required amount of cement is %.f bags.\nRequired volume of Fine Aggregate is %.2f cu ft.\nRequired volume of Coarse Aggregate is %.2f cu ft.\nRequired amount of Water is %.2f gallons ",CEMENT,FA,CA,AMT_WATER); getch(); } Input: Output: /* Program No. : 08

Name of The Program: To find the summation of series 𝟏

𝑳𝟑+

𝟏

𝑳𝟓+

𝟏

𝑳𝟕+

𝟏

𝑳𝟗

………..up to 100 terms. Programmed By: KUNDAN YADAV Student ID: 1507365 */ #include<stdio.h> #include<conio.h> #include<math.h> void main() { int n,L; float Sum; clrscr(); printf("Enter the value of L:\n"); scanf("%d",&L); Sum=0; for(n=1; n<=100; n++) { Sum=Sum+(1/pow(L,(2*n+1))); } printf("The required summation is %f",Sum); getch(); } Input: Output: /* Program No. : 09

Name Of The Program: To read and write a matrix using Array. Programmed By: KUNDAN YADAV Student ID: 1507365 */ #include <stdio.h> #include <conio.h> #include <math.h> void main() { float A[100][100]; int a,b,i,j; clrscr(); printf("Enter the value of rows and columns of requried matrix\n"); scanf("%d%d",&a,&b); printf("Fill the data according to instruction\n"); for(i=1; i<=a; i++) { for(j=1; j<=b; j++) { printf("A%d%d\n",i,j); scanf("%f",&A[i][j]); } } printf("Entered Matrix is\n\n"); printf("%f\t%f\t%\n\n",A[i][j] getch(); } for(i=1; i<=a; i++) { for(j=1; j<=b; j++) { printf("%f\t",A[i][j]); } printf("\n\n"); } getch(); } Input:

Output: /* Program No. : 10

Name of The Program: To find the solution of Interpolation problem up to 4 data. Programmed By: KUNDAN YADAV Student ID: 1507365 */ #include<stdio.h> #include<conio.h> #include<math.h> void main() { int i,a; float X[4],Y[4],x,y,p,h; clrscr(); printf("This program can only calculate the interpolation problem up to 4 data.\n"); printf("\nEnter the data number (below 5):\n"); scanf(" %d",&a); if(a!=1 && a!=2 && a!=3 && a!=4) { printf("Invalid data............. Press any key to exit"); } if(a==4 || a==3 ||a==2 || a==1) { printf("\nEnter the data according to instructions\n\n"); for(i=0; i<=(a-1); i++) { printf("X%d :\n",i); scanf(" %f",&X[i]); printf("Y%d :\n",i); scanf(" %f",&Y[i]); } printf("\n\nEnter the value of x, for which correspond value y is required:\n"); scanf(" %f",&x); h=X[1]-X[0]; p=(x-X[0])/h; if(a==4) { y=Y[0]+p*(Y[1]-Y[0])+((pow(p,2)-p)*(Y[2]-2*Y[1]+Y[0]))/2+((pow(p,3)-3*pow(p,2)+2*p)*(Y[3]-3*Y[2]+3*Y[1]-Y[0]))/6; } if(a==3) { y=Y[0]+p*(Y[1]-Y[0])+((pow(p,2)-p)*(Y[2]-2*Y[1]+Y[0]))/2; } if(a==2)

{ y=Y[0]+p*(Y[1]-Y[0]); } if(a==1) { y=Y[0]; } printf(" \n\nThe Correspond value of y for x=%.2f is %.2f\n\n",x,y); printf("Pressing any key makes you exit"); } getch(); } Input: Output: /* Program No. : 11

Name of The Program: To find the multiplication of two matrices. Programmed By: KUNDAN YADAV Student ID: 1507365 */ #include<stdio.h> #include<conio.h> #include<math.h> void main() { int rA,cA,rB,cB,i,j,k,Sum; float A[50][50],B[50][50],C[50][50]; clrscr(); printf("No. of rows of Matrix A:\n"); scanf(" %d",&rA); printf("No. of Columns of Matrix A:\n"); scanf(" %d",&cA); printf("No. of rows of Matrix B:\n"); scanf(" %d",&rB); printf("No. of rows of Matrix B:\n"); scanf(" %d",&cB); if(cA!=rB) { printf("Invalid input...........Press any key to exit"); } else { for(i=1; i<=rA; i++) { for(j=1; j<=cA; j++) { printf("Enter the value A%d%d\n",i,j); scanf(" %f",&A[i][j]); } } for(i=1; i<=rB; i++) { for(j=1; j<=cB; j++) { printf("Enter the value B%d%d\n",i,j); scanf(" %f",&B[i][j]); } } for(i=1; i<=rA; i++) { for(j=1; j<=cB; j++)

{ Sum=0; for(k=1; k<=rA; k++) { Sum=Sum+A[i][k]*B[k][j]; C[i][j]=Sum; } } } printf("The resultant matrix is:\n"); for(i=1; i<=rA; i++) { for(j=1; j<=cB; j++) { printf(" %.f\t",C[i][j]); } printf("\n\n\n"); } } getch(); } Input: Output: /* Program No. : 12

Name of The Program: To find the inverse of matrix. Programmed By: KUNDAN YADAV Student ID : 1507365 */ #include <stdio.h> #include <conio.h> #include <math.h> void main() { float A[50][50],det,Ac[50][50],At[50][50],Ai[50][50]; int i,j,a,b; char press; clrscr(); printf("This program can only Calculate the inverse of Matrix 2 X 2 and Matrix 3 X 3\n\n"); printf("1.To Calculate the inverse of Matrix 2 X 2, Press 1\n2.To Calculate the inverse of Matrix 3 X 3, Press 2\n\n"); scanf(" %c",&press); if(press!='1' && press!='2') { printf("\n\nInvalid data\n\n"); printf("Press any key to exit....."); } else { printf("\nEnter the data according to instructions:\n\n"); if(press=='1') { for(i=1; i<=2; i++) { for(j=1; j<=2; j++) { printf("A%d%d\n",i,j); scanf("%f",&A[i][j]); } } det=A[1][1]*A[2][2]-A[1][2]*A[2][1]; if(det==0) { printf("\n\nInvalid..........Press any key to exit"); } else { Ac[1][1]=A[2][2]; Ac[1][2]=-(A[2][1]);

Ac[2][1]=A[1][2]; Ac[2][2]=-(A[1][1]); a=2; b=2; for(i=1; i<=a; i++) { for(j=1; j<=b; j++) { At[i][j]=Ac[j][i]; Ai[i][j]=(1/det)*At[i][j]; } } } } if(press=='2') { for(i=1; i<=3; i++) { for(j=1; j<=3; j++) { printf("A%d%d\n",i,j); scanf("%f",&A[i][j]); } } det=A[1][1]*(A[2][2]*A[3][3]-A[2][3]*A[3][2])-A[1][2]*(A[2][1]*A[3][3]-A[2][3]*A[3][1])+A[1][3]*(A[2][1]*A[3][2]-A[2][2]*A[3][1]); if(det==0) { printf("\n\nInvalid........Press any key to exit"); } else { Ac[1][1]=A[2][2]*A[3][3]-A[2][3]*A[3][2]; Ac[1][2]=-(A[2][1]*A[3][3]-A[2][3]*A[3][1]); Ac[1][3]=A[2][1]*A[3][2]-A[2][2]*A[3][1]; Ac[2][1]=-(A[1][2]*A[3][3]-A[1][3]*A[3][2]); Ac[2][2]=A[1][1]*A[3][3]-A[1][3]*A[3][1]; Ac[2][3]=-(A[1][1]*A[3][2]-A[1][2]*A[3][1]); Ac[3][1]=A[1][2]*A[2][3]-A[1][3]*A[2][2]; Ac[3][2]=-(A[1][1]*A[2][3]-A[1][3]*A[2][1]); Ac[3][3]=A[1][1]*A[2][2]-A[1][2]*A[2][1]; a=3; b=3; for(i=1; i<=a; i++) { for(j=1; j<=b; j++) { At[i][j]=Ac[j][i];

Ai[i][j]=(1/det)*At[i][j]; } } } } printf("\n\nThe inverse of given Matrix is:\n"); for(i=1; i<=a; i++) { for(j=1; j<=b; j++) { printf(" %.f\t",Ai[i][j]); } printf("\n\n\n"); } } getch(); } Input: Output: /* Program No. : 13

Name of The Program: To solve a system of equations for 3 unknowns. Programmed By: KUNDAN YADAV Student ID: 1507365 */ #include <stdio.h> #include <conio.h> #include <math.h> void main() { float A[50][50],D[50],det,Ac[50][50],At[50][50],Ai[50][50],SUM,Unknown[50]; int i,j; FILE*output; clrscr(); printf("Arrange the equations in A11x+A12y+A13z=D1, A21x+A22y+A23z=D2...and Fill the data according to instruction\n"); for(i=1; i<=3; i++) { for(j=1; j<=3; j++) { printf("A%d%d\n",i,j); scanf("%f",&A[i][j]); } } for(j=1; j<=3; j++) { printf("D%d\n",j); scanf("%f",&D[j]); } det=A[1][1]*(A[2][2]*A[3][3]-A[2][3]*A[3][2])-A[1][2]*(A[2][1]*A[3][3]-A[2][3]*A[3][1])+A[1][3]*(A[2][1]*A[3][2]-A[2][2]*A[3][1]); if(det==0) { printf("Invalid"); } else { output=fopen("D:\\bar.txt","w"); fprintf(output,"Determinant of Given System is %.2f\n",det); Ac[1][1]=A[2][2]*A[3][3]-A[2][3]*A[3][2]; Ac[1][2]=-(A[2][1]*A[3][3]-A[2][3]*A[3][1]); Ac[1][3]=A[2][1]*A[3][2]-A[2][2]*A[3][1]; Ac[2][1]=-(A[1][2]*A[3][3]-A[1][3]*A[3][2]); Ac[2][2]=A[1][1]*A[3][3]-A[1][3]*A[3][1]; Ac[2][3]=-(A[1][1]*A[3][2]-A[1][2]*A[3][1]); Ac[3][1]=A[1][2]*A[2][3]-A[1][3]*A[2][2];

Ac[3][2]=-(A[1][1]*A[2][3]-A[1][3]*A[2][1]); Ac[3][3]=A[1][1]*A[2][2]-A[1][2]*A[2][1]; for(i=1; i<=3; i++) { for(j=1; j<=3; j++) { At[i][j]=Ac[j][i]; Ai[i][j]=(1/det)*At[i][j]; } } for(i=1; i<=3; i++) { SUM=0; for(j=1; j<=3; j++) { SUM=SUM+Ai[i][j]*D[j]; } fprintf(output,"Unknown%d = %.2f\n",i,SUM); } } getch(); } Input: Output: /* Program No. : 14

Name of The Program: To show a tabular result of RL at different points. Programmed By: KUNDAN YADAV Student ID: 1507365 */ void main() { int i, number; float RL_BM, SR_BM, SR_[1000], RL_[1000], RL_LOC; clrscr(); printf("Enter the RL of Bench Mark (in metre) and Staff reading on BM(in mm):\n"); scanf("%f %f",&RL_BM, &SR_BM); printf("Enter total number of staff(excluding BM): "); scanf("%d",&number); for(i=1;i<=number;i++) { printf("Enter the value of staff reading on point %d (in mm): ",i); scanf("%f",&SR_[i]); RL_LOC=RL_BM+(SR_BM/1000); } printf("\nStaff Station: \t\t RL(in metre):\n"); for(i=1;i<=number;i++) { printf("Point %d \t\t %.2f\n", i, (RL_LOC-(SR_[i])/1000)); /* RL_[i]=RL_LOC-SF_[i]*/ } getch(); } Input: Output: /* Program No. : 15

Name of The Program: To calculate shear force, bending moment, shear stress and bending stress at anywhere of the given beam. Programmed By: KUNDAN YADAV Student ID: 1507365 */ #include<stdio.h> #include<conio.h> #include<math.h> void main() { float W1,W2,P,L1,L2,L3,a,b,x,R1,R2,Vx,Mx,Vx1,Vx2,c,h,I,Q,Ss,Sb; clrscr(); printf("Input L1, L2, L3, P, W1, W2, b and h in MKS units \n\n"); scanf(" %f%f%f%f%f%f%f%f",&L1,&L2,&L3,&P,&W1,&W2,&b,&h); printf("Enter the distance from left to right at which point calculation is needed:\n"); scanf(" %f",&x); if(x>(L1+L2+L3)) { printf("Invalid data...........Press any key to exit"); } else { R1=(1/(L3+L2))*(W1*L3*(0.5*L3+L2)+P*L2-0.5*L1*W2*L1*(2/3)); R2=(W1*L3+P+0.5*W2*L1)-R1; if(x>0 && x<L3) { Vx=R1-W1*x; Mx=R1*x-W1*0.5*pow(x,2); } if(x>L3 && x<(L3+L2)) { Vx=R1-W1*L3-P; Mx=R1*x-W1*L3*(x-0.5*L3)-P*(x-L3); } if(x>(L3+L2) && x<=(L3+L2+L1)) { Vx=R1-W1*L3-P+R2-(0.5*(W2/L1)*(x-L3-L2)); Mx=R1*x-W1*x*(x-0.5*L3)-P*(x-L3)+R2*(x-L3-L2)-0.5*(W2/L1)*pow((x-L3-L2),2)*(1/3); }

if(x==L3) { Vx1=R1-W1*L3; Vx2=R1-W1*L3-P; if(Vx1>Vx2) { Vx=Vx1; } else { Vx=Vx2; } } if(x==(L3+L2)) { Vx1=R1-W1*L3-P; Vx2=R1-W1*L3-P+R2; if(Vx1>Vx2) { Vx=Vx1; } else { Vx=Vx2; } } c=h/2; I=b*pow(h,3)/12; Q=b*pow(h,2)/8; Ss=Vx*Q/(I*b); Sb=Mx*(c/I); printf("\n\nAt a distance %.2f m from left end\nShear force = %.2f N\nBending moment = %.2f N-m\nShear stress = %.2f N/sq.m\tand\nBending shear = %.2f N/sq.m\n",x,Vx,Mx,Ss,Sb); printf("\n\nPressing any key makes you exit........"); } getch(); } Input:

Output: /* Program No. : 16

Name of The Program: To calculate for shear force, bending moment, shear stress and bending stress at anywhere of the given cantilever beam. Programmed By: KUNDAN YADAV Student ID: 1507365 */ #include<stdio.h> #include<conio.h> #include<math.h> #define R 15 #define M 60 void main() { float x,Vx,Mx; clrscr(); printf("Enter the distance (in ft) at which shear force and bending moment is required:\n(from left to right) \n"); scanf(" %f",&x); if(x>=0 && x<=2) { Vx=R; Mx=R*x-M; } if(x>2 && x<=5) { Vx=R-(5/3)*(x-2); Mx=(R*x)-M-((5/9)*pow((x-2),2)); } printf("At a distance %.2f ft from left \nShear force = %.2f N\nBending moment = %.2f N-m\n\n",x,Vx,Mx); printf("Pressing any key makes you exit........"); getch(); } Input: Output:

/* Program No. : 17

Name of The Program: To calculate stress in a member due to change in temperature. Programmed By: KUNDAN YADAV Student ID: 1507365 */ #include<stdio.h> #include<conio.h> #include<math.h> void main() { float T1,T2,S,ALPHA,E; char Type; clrscr(); printf("Enter initial and final temperature respectively\n\n"); scanf("%f%f",&T1,&T2); E=200*pow(10,9); ALPHA=11.7*pow(10,-6); if(T1>T2) { Type==Compression } if(T1<T2) { Type==Tensile } S=ALPHA*E*(T1-T2); printf("Stress due to temperature is %.2f in N/sq.m which is %c\n",S,Type); getch(); } Input: Output: /* Program No. : 18

Name of The Program: Unit conversion of Pressure, Load and Volume. Programmed By: KUNDAN YADAV Student ID : 1507365 */ #include <stdio.h> #include <conio.h> #include <math.h> void main() { float VALUE,CVALUE; int CHOICE,CHOICE1; clrscr(); printf("A program for Unit conversion of Pressure,Load and Volume.\n\t\tProgrammed By Kundan\n\t\tProgrammer ID: 1507365\n\n"); printf("Choose your Conversion:\n\tPress 1 for Pressure\n\tPress 2 for Load\n\tPress 3 for Volume\n\n"); scanf(" %d", &CHOICE); if(CHOICE==1) { printf("Enter the Value for Conversion:"); scanf(" %f",&VALUE); printf("\n\n\tPress 1 for Newton per sq.meter to psi\n\tPress 2 for psi to Newton per sq.meter\n"); scanf(" %d",&CHOICE1); if(CHOICE1==1) { CVALUE=VALUE*0.000145; printf("The Coverted value of %.2f Newton per sq.meter is %.2f psi.\n\n",VALUE,CVALUE); } if(CHOICE1==2) { CVALUE=VALUE*6894.76; printf("The Coverted value of %.2f psi is %.2f Newton per sq.meter.\n\n",VALUE,CVALUE); } } if(CHOICE==2) { printf("Enter the Value for Conversion:"); scanf(" %f",&VALUE); printf("\n\n\tPress 1 for Newton to Pound force\n\tPress 2 for Pound force to Newton\n"); scanf(" %d",&CHOICE1); if(CHOICE1==1)

{ CVALUE=VALUE*0.225; printf("The Coverted value of %.2f Newton is %.2f Pound force.\n\n",VALUE,CVALUE); } if(CHOICE1==2) { CVALUE=VALUE*4.44822; printf("The Coverted value of %.2f Pound force is %.2f Newton.\n\n",VALUE,CVALUE); } } if(CHOICE==3) { printf("Enter the Value for Conversion:"); scanf(" %f",&VALUE); printf("\n\n\tPress 1 for cubic meter to cubic feet\n\tPress 2 for cubic feet to cubic meter\n"); scanf(" %d",&CHOICE1); if(CHOICE1==1) { CVALUE=VALUE*35.31466672; printf("The Coverted value of %.2f cubic meter is %.2f cubic feet.\n\n",VALUE,CVALUE); } if(CHOICE1==2) { CVALUE=VALUE*0.02831684; printf("The Coverted value of %.2f cubic feet is %.2f cubic meter.\n\n",VALUE,CVALUE); } } getch(); } Input: Output: /* Program No. : 19

Name of The Program: To calculate bar length for circular foundation. Programmed By: KUNDAN YADAV Student ID: 1507365 */ #include <stdio.h> #include <conio.h> #include <math.h> void main() { float D,Db,R,S,C,L,x=0; clrscr(); printf("This program can calculate bar lengths for circular slab.\n\n"); printf("Enter the diameter of foundation(m), clear cover(mm) and bar spacing(mm):\n"); scanf(" %f%f%f",&D,&C,&S); Db=D-2*C*.001; R=Db/2; printf("\n\n\tDistance(m)\t\tBar Length(m)\n"); do { L=2*pow((R*R-x*x),0.5); printf("\t%.3f\t\t\t%.3f\n",x,L); x=x+0.001*S; } while(x<R); printf("\n\nPressing any key makes you exit.........."); getch(); } Input: Output: /* Program No. : 20

Name of The Program: To calculate bar length for triangular slab. Programmed By: KUNDAN YADAV Student ID: 1507365 */ #include <stdio.h> #include <conio.h> #include <math.h> void main() { float b,h,S,L,x=0; clrscr(); printf("This program can calculate bar lengths for Triangular slab.\n\n"); printf("Enter the base of triangular slab (in m), its height(in m) and bar spacing(in mm) :\n"); scanf(" %f%f%f",&b,&h,&S); printf("\n\n\tDistance(m)\t\tBar Length(m)\n"); do { L=(b/h)*(h-x); printf("\t%.3f\t\t\t%.3f\n",x,L); x=x+0.001*S; } while(x<h); printf("\n\nPressing any key makes you exit.........."); getch(); } Input: Output:

top related