Вы находитесь на странице: 1из 24

1

/*TRANSPOSE OF MATRIX */
#include<stdio.h>
#include<conio.h>
#define max 10
void main()
{
int a[max][max],b[max][max];
int j,k,r1,c1;
clrscr();
printf("enter value of rows and columns:\n");
scanf("%d %d",&r1,&c1);
printf("enter the matrix:");
for(j=0;j<r1;j++)
{
for(k=0;k<c1;k++)
{
scanf("%d",&a[j][k]);
}
}
printf("\ngiven matrix is:\n");
for(j=0;j<r1;j++)
{
for(k=0;k<c1;k++)
{
printf("%d\t",a[j][k]);
}
printf("\n");
}
for(j=0;j<r1;j++)
{
for(k=0;k<c1;k++)
{
b[k][j]=a[j][k];
}
}
printf("\ntranspose of given matrix is:\n");
for(k=0;k<r1;k++)
{
for(j=0;j<c1;j++)
{
printf("%d\t",b[k][j]);
}
printf("\n");
}

getch();
}

enter value of rows and columns:


4 4
enter the matrix:1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16
given matrix is:
1
2
3
5
6
7
9
10
11
13
14
15

4
8
12
16

transpose of given matrix is:


1
5
9
13
2
6
10
14
3
7
11
15
4
8
12
16

//multiplication of two matrices //


#include<stdio.h>
#include<conio.h>
main()
{
int i,j,k,m,n,p;
int a[5][5],b[5][5],c[5][5];
clrscr();
printf("enter size of matrix a:");
scanf("%d%d",&m,&n);
printf("\nenter no of column b:");
scanf("%d",&p);
printf("\nenter elements for matrix a:");

for(i=0;i<m;i++)
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
}
printf("\nenter elements for matrix b:");
for(i=0;i<n;i++)
for(j=0;j<p;j++)
{
scanf("%d",&b[i][j]);
}
for(i=0;i<m;i++)
for(j=0;j<p;j++)
{
c[i][j]=0;
for(k=0;k<n;k++)
c[i][j]+=a[i][k]*b[k][j];
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%d\t",a[i][j]);
}
printf("\n");
}
printf("\n\n");
for(i=0;i<n;i++)
{
for(j=0;j<p;j++)
{
printf("%d\t",b[i][j]);
}
printf("\n");
}
printf("\n\n");
for(i=0;i<m;i++)
{
for(j=0;j<p;j++)
{
printf("%d\t",c[i][j]);
}
printf("\n");

}
getch();
return (0);
}

enter size of matrix a:3


3
enter no of column b:3
enter elements for matrix a:1 2 3 4 5 6 7 8 9
enter elements for matrix b:1 2 3 4 5 6 7 8 9
1
2
3
4
5
6
7
8
9
1
4
7

2
5
8

3
6
9

30
66
102

36
42
81
96
126 150

3 /*Write a program to calculate factorial of a given no


RECURSION*/
#include<stdio.h>
#include<conio.h>
main()
{
int n;
long fact;
clrscr();

by

printf("Enter a number:");
scanf("%d",&n);
fact=factorial(n);
printf("factorial of %d is %ld\n",n,fact);
}
factorial(n)
int n;
{
long fact;
if(n<=0)
return (1);
else
fact = n * factorial(n-1);
return(fact);
}

Enter a number:5
factorial of 5 is 120

4 /* Write a program to print REVERSE string using ARRAY*/


#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i=9;
char a[10];
clrscr();
printf("Enter the string:\n");
scanf("%s",&a);
while(i>=0)
{
printf("%c",a[i]);
i--;
}
getch();
}

Enter the string:


abcdefghij
jihgfedcba

/*Write a program to design steel compresion


for a given compressive force. */

#include<stdio.h>
#include<conio.h>
#include<math.h>
#define PI=3.1416
void main()
{
int i,sr1,sr2,ac1,ac2,k;
float n,sr,fck,fcc,fy,ac,t,area,r,ag,cs,p,le,P;
clrscr();
printf("Give eff lenth of column(mm):");
scanf("%f",&le);
printf("\nGive permissible comp stress(N/mm^2):");
scanf("%f",&cs);
printf("\nGive load(kN):");
scanf("%f",&p);
area=p*1000/cs;
printf("Area is %f",area);
printf("\nGive appropriate section with Agross(cm^2) &
r(min)mm:");
scanf("%ld %f %f",&i,&ag,&r);
sr=le/r;
printf("\nMaximum slenderness ratio is :%f",sr);
if(sr<180)
{
printf("\nAllright");
printf("\nGive value of fy(n/mm^2):");
scanf("%d",&fy);
printf("\nEnter value ofsr1:");
scanf("%d",&sr1);
printf("\nEnter value of sr2:");
scanf("%d",&sr2);

member

//

printf("\nGive value of ac corresponding to sr1:");


scanf("%d",&ac1);
printf("\nGive value of ac corresponding to sr2:");
scanf("%d",&ac2);
t=sr-sr1;
//
printf("\nt is %f",t);
//
k=ac1-ac2;
//
printf("\nk= %d",k);
ac=ac1-((ac1-ac2)*(sr-sr1)/10);
printf("\nac is %f",ac);
P= ac*ag*100/1000;
printf("\nsafe load is %f kN",P);
if(P>p)
printf("\nsafe");
else
printf("\nunsafe");
}
else
printf("redesign");
getch();
}

Give eff lenth of column(mm):1785


Give permissible comp stress(N/mm^2):68
Give load(kN):97
Area is 1426.470581
Give appropriate section with Agross(cm^2) & r(min)mm:808010
15.05
15.5
Maximum slenderness ratio is :115.161293
Allright
Give value of fy(n/mm^2):250
Enter value ofsr1:110
Enter value of sr2:120

Give value of ac corresponding to sr1:72


Give value of ac corresponding to sr2:64
ac is 67.870964
safe load is 102.145805 kN
safe

/* write a program to compute diameter and no of bars


for a given beam section */
#include<stdio.h>
#include<math.h>
#include<conio.h>
#define PI 3.1416
void main()
{
int fck,fy,c,n;
float D,d,L,b,dc,temp,temp1,s;
double Mu,Xumax,Astr,Astp,Mumax;
clrscr();
printf("Enter value of fck(N/mm^2)");
scanf("%d",&fck);
printf("\nEnter value of fy(N/mm^2)");
scanf("%d",&fy);
printf("\nEnter value of width (mm) ");
scanf("%f",&b);
printf("\nEnter value of overall depth(mm)");
scanf("%f",&D);
printf("\nEnter value of effective cover dc(mm)");
scanf("%f",&dc);
printf("\nEnter value moment of resistance(Nmm)");
scanf("%lf",&Mu);
d=D-dc;
Xumax=700*d/(100+0.87*fy);
Mumax=0.36*fck*b*Xumax*(d-0.42*Xumax);
if(Mu<Mumax)
{
printf("\nSection is under reinforced.");
Astr=(0.5*fck*b*d*(1.0 - (sqrt(1-4.6*Mu/(fck*b*d*d)))))/fy;

printf("\nAst reqd is %lf",Astr);


printf("\nEnter value of Ast provided:");
scanf("%lf",&Astp);
printf("\nEnter dia of bar:");
scanf("%d",&c);
n=Astp*4/(PI*c*c);
printf("\nProvide %d no of %d mm steel bars.",n,c);
}
else
printf("\n section is over reinforced.");
getch();
}

Enter value of fck(N/mm^2)20


Enter value of fy(N/mm^2)500
Enter value of width (mm) 200
Enter value of overall depth(mm)400
Enter value of effective cover dc(mm)40
Enter value moment of resistance(Nmm)60e+6
Section is under reinforced.
Ast reqd is 455.317310
Enter value of Ast provided:460
Enter dia of bar:12
Provide 4 no of 12 mm steel bars.

7//DOME MS AND HS//


#include<stdio.h>
#include<math.h>
#include<conio.h>
#define pi 3.1415
main()

{
int no;
float w,W,r,th,HSudl,HSptl,HS,MS,i;
clrscr();
printf("enter the type of loading:");
printf("\nCASE 1:UDL");
printf("\nCASE 2:POINT LOAD");
printf("\nCASE 3:UDL+POINT LOAD");
scanf("%d",&no);
switch(no)
{
case 1:
printf("enter the value of UDL W:");
scanf("%f",&W);
printf("\nenter the value of r:");
scanf("%f",&r);
printf("\nenter the value of theeta:");
scanf("%f",&th);
for(i=0;i<=th;i+=10)
{
MS=(W*r)/(1+cos(i));
HS=W*r*(cos(i)-(1/(1+cos(i))));
printf("\nMS at %.2f is=%.2f",i,MS);
printf("\nHS at %.2f is=%.2f",i,HS);
}
break;
case 2:
printf("enter the value of POINT LOAD W:");
scanf("%f",&W);
printf("\nenter the value of r:");
scanf("%f",&r);
printf("\nenter the value of theeta:");
scanf("%f",&th);
for(i=0;i<=th;i++)
{
MS=W/(2*pi*sin(i));
HS=-W/(2*pi*sin(th)*sin(th));
printf("\nMS at %.2f is=%.2f",i,MS);
printf("\nHS at %.2f is=%.2f",i,HS);
}
break;
case 3:
printf("enter the value of UDL W:");
scanf("%f",&W);
printf("\nenter value of pt load w:");
scanf("%f",&w);
printf("\nenter the value of r:");

scanf("%f",&r);
printf("\nenter the value of theeta:");
scanf("%f",&th);
for(i=0;i<=th;i+=10)
{
MS=((W*r)/(1+cos(i)))+(w/(2*pi*sin(i)));
HSudl=W*r*(cos(i)-(1/(1+cos(i))));
HSptl=-w/(2*pi*r*sin(th)*sin(th));
HS=HSudl+HSptl;
printf("\nMS at %.2f is=%.2f",i,MS);
printf("\nHS at %.2f is=%.2f",i,HS);
}
break;
}
getch();
}

8/*Write a program to compute EULER's BUCKLING load in a column:*/


#include<stdio.h>
#include<conio.h>
#include<math.h>
#define PI 3.141567
void main()
{ int ic;
float l,le;
double e,i,pcr;
clrscr();
printf("Give the value of e,i,l: ");
scanf("%lf %lf %f",&e,&i,&l);
printf("\nCase:1=Both ends are fixed:");
printf("\nCase:2=One end is fixed & other is hinged:");
printf("\nCase:3=One end is fixed & other is free:");
printf("\nCase:4=Both end are hinged:");
printf("\nGive case no:");
scanf("%d",&ic);
if(ic==1)
le=l/2.0;
else if (ic==2)
le=l/sqrt(2.0);
else if (ic==3)
le=l;

else if (ic==4)
le=2.0*l;
pcr=PI*PI*e*i/(le*le);
printf("\nEuler's crippling load=%3lf",pcr);
getch();
}

9/*Write a program to prepare a FLOYED triangle in following way:


1
2 3
4 5 6
7 8 9 10
*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,m,n,k,a=1;
clrscr();
printf("\n Enter any number:");
scanf("%d",&n);
m=n-1;
for(i=1;i<=n;i++)
{
printf("\t");
k=0;
while(k<=m)
{
printf(" ");
k++;
}
m--;
for(j=1;j<=i;j++)
{

printf("%d",a);
a++; //(here u can print i also,result will be
differ.)
printf("

");

}
printf("\n");
}
getch();
}

10/* Write a program to prepare a FLOYED triangle in following


way:
1
2 3
4 5 6
7 8 9 10
*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,a=1,n;
clrscr();
printf("\nenter no:");
scanf("%d",&n);
for (i=1;i<=n;i++)
{
for (j=1;j<=i;j++)
{
printf(" %3d ",a);
a++;
}
printf("\n");
}
getch();
}

11//CANTILEVER BEAM WITH UDL :SLOPE & DEF//

#include<stdio.h>
#include<conio.h>
void main()
{
int i=0,j,n;
float w,l,EI,SLOPEx,DEFx,x;
clrscr();
printf("CANTILEVER BEAM:");
printf("\nEnter the udl in kN/m and span in m");
scanf("%f%f",&w,&l);
printf("\ngive the no.of parts and EI in kN/m^2:");
scanf("%d%f",&n,&EI);
printf("\n|| x || SLOPx || DEFx ||\n");
while(i<=n)
{
x=i*l/n;
SLOPEx=w*x*x*x/(6*EI);
DEFx=w*x*x*x*x/(8*EI);
printf("\n||%7.3f|| %7.3f || %7.3f ||",x,SLOPEx,DEFx);
i++;
}
printf("\n");
getch();
}

12
// SHEAR CARRYING CAPACITY //
#include<stdio.h>
#include<math.h>
#include<conio.h>
#define PI 3.142857
main()
{
float b,d,n,dia,sv,fck,fy;
float ast,pt,B,tc,Vu,Asv,Vus,tot;
clrscr();
printf("Enter the width(b) and depth(d) of beam:");
scanf("%f %f",&b,&d);
printf("Enter the dia of bars and no of bars provided in beam:");
scanf("%f %f",&dia,&n);
printf("\nEnter the spacing between the bars:");
scanf("%f",&sv);

printf("Enter the value of fck and fy:");


scanf("%f %f",&fck,&fy);
ast=(n*PI*dia*dia)/4;
pt=(100*ast)/(b*d);
B=(0.8*fck)/(6.89*pt);
tc=((0.85*sqrt(0.8*fck))*(sqrt(1+(5*B))-1))/(6*B);
Vu=(tc*b*d);
Asv=(PI*dia*dia)/4;
Vus=(0.87*fy*Asv*d)/sv;
printf("\nSHEAR CARRYING BY CONCRETE =%fkN/m",Vu);
printf("\nSHEAR CARRYING BY REINFORCEMENT =%fkN/m",Vus);
tot=Vu+Vus;
printf("\nTOTAL SHEAR VARRYING CAPACITY OF BEAM =%fkN/m",tot);
getch();
}

13
//INTERPOLATION//
#include<stdio.h>
#include<conio.h>
main()
{
float l1,l2,ps1,ps2;
float l,a,ps;
clrscr();
printf("Enter the value of lambda==>");
scanf("%f",&l);
printf("Enter the value of l1(l1<l2)==>");
scanf("%f",&l1);
printf("\nEnter the value of l2==>");
scanf("%f",&l2);
printf("\nEnter the value of ps1 for l1==>");
scanf("%f",&ps1);
printf("\nEnter the value of ps2 for l2==>");
scanf("%f",&ps2);
ps=ps1-(((ps1-ps2)*(l-l1))/(l2-l1));
printf("\nPERMISSIBLE STRESS FOR GIVEN VALUE OF LAMBDA %2f IS
%.2fMPa",l,ps);
getch();
}

14//RESULTANT OF COPLANNAR CONCURRENT FORCES//


#include<stdio.h>
#include<conio.h>
#include<math.h>
#define PI 3.142857
main()
{
int n,i;
double P[10],th[10];
double Rx,Ry,R,theeta[10];
clrscr();
printf("Enter number of forces");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("\nEnter force P%d in N\t",i);
scanf("%lf",&P[i]);
printf("Enter th%d in degree\t",i);
scanf("%lf",&th[i]);
theeta[i]=th[i]*PI/180;
Rx+=P[i]*cos(theeta[i]);
Ry+=P[i]*sin(theeta[i]);
}
printf("\n\n");
printf("\n\tNUMBER FORCE(N) ANGLE(DEGREE)");
for(i=1;i<=n;i++)
{
printf("\n\t %d %7.2lf %7.2lf",i,P[i],th[i]);
}
R=sqrt(pow(Rx,2)+pow(Ry,2));
printf("\n\n\tTHE RESULTANT R IS= %.2lfN",R);
getch();
}

15

/*addition of two matrices*/


#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],b[3][3],c[3][3];
int j,k;
clrscr();

printf("enter the matrix1:");


for(j=0;j<3;j++)
{
for(k=0;k<3;k++)
{
scanf("%d",&a[j][k]);
}
}
printf("enter the matrix2:");
for(j=0;j<3;j++)
{
for(k=0;k<3;k++)
{
scanf("%d",&b[j][k]);
}
}
for(j=0;j<3;j++)
{
for(k=0;k<3;k++)
{
c[j][k]=a[j][k]+b[j][k];
}
}
printf("\nsum of two matrix is:\n");
for(j=0;j<3;j++)
{
for(k=0;k<3;k++)
{
printf("%d\t",c[j][k]);
}
printf("\n");
}
getch();
}

16/* write a program for MATRIX INVERSION */


#include<stdio.h>
#include<conio.h>
main()
{
int i,j,k,n,c,row,col;
float m,temp,a[10][10];

clrscr();
printf("enter the value of rows and cols");
scanf("%d %d",&n,&c);
printf("\nenter the value of matrix row wise\n");
for(i=1;i<=n;++i)
{
for(j=1;j<=n;++j)
{
scanf("%f",&temp);
a[i][j]=temp;
}
}
for(i=1;i<=n;++i)
{
m=a[i][i];
a[i][i]=1.0;
for(j=1;j<=n;++j)
a[i][j]=a[i][j]/m;
for(k=1;k<=n;++k)
{
if((k-1)!=0)
{
m=a[k][i];
a[k][i]=0.0;
for(j=1;j<=n;++j)
{
a[k][i]=a[k][j]-m*a[i][j];
}
}
}
}
printf("\nInverse :\n");
for(i=1;i<=n;++i)
{
for(j=1;j<=n;++j)
{
printf("\t%7.2f",a[i][j]);
}
printf("\n");
}
getch();
}

17/* Write a program to prepare a list of PRIME nos from 1 to n


:*/
#include<stdio.h>
#include<conio.h>
void main()
{
int no,i,j,k;
clrscr();
printf("Enter the no upto which you want PRIME nos:");
scanf("%d",&no);
for(i=2;i<=no;i++)
{
for(j=2;j<i;j++)
{
k=i%j;
if(k==0)
break;
else
printf("%d",j);
}
}
printf("\n");
getch();
}

18//To find the ordinates of displacement curve for Cantilever


beam with udl//
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float w,l;
int x;
double E,I,dis;
clrscr();

printf("Give load w(kN) & lenth l(m):");


scanf("%f %f",&w,&l);
printf("\nGive E & I");
scanf("%lf %lf",&E,&I);
for(x=0;x<=l;++x)
{
dis=(w*x*x*x*x)/(8.0*E*I);
printf("Displacement at %d is :%lf\n",x,dis);
}
getch();
}

19/*program to tabulate ordinates of ild for ssb with overhang */


#include<stdio.h>
#include<conio.h>
void main()
{
float L1,L2,L3,sec,sf,bm,Ra,Rb,L;
int x;
clrscr();
printf("\nenter the value of L1,L2,L3 and section:");
scanf("%f %f %f",&L1,&L2,&L3,&sec);
L=L1+L2;
printf("\nthe ordinates of Ra and Rb are as follows:");
for(x=0;x<=(L+L3);x++)
{
Ra=(L-x)/L2;
Rb=1-Ra;
printf("\nat interval x=%d\tRa=%2.2f\tRb=%2.2f",x,Ra,Rb);
}
printf("\nthe ordinates of sf and bm:");
if(sec<L1)
{
for(x=0;x<=sec;x++)
{
sf=L;
bm=(sec-x);
printf("\nat interval x=%d\t sf=%2.2f\t bm=%2.2f",x,sf,bm);
}
for(x=sec;x<=(L+L3);x++)
{
printf("\nat interval x=%d\t sf=0\t bm=0",x);
}

}
if(sec>L1 && sec<L)
{
for(x=0;x<=sec;x++)
{
sf=L-((L-x)/L2);
bm=((L-x)/L2)*(sec-L1);
printf("\nat interval x=%d\t sf=%2.2f\t bm=%2.2f",x,sf,bm);
}
/* for(x=0;x<=sec;x++)
{
sf=L-((L-x)/L2);
bm=((L-x)/L2)*(sec-L1);
printf("\nat interval x=%d\t sf=%2.2f\t bm=%2.2f",x,sf,bm);
}*/
for(x=sec;x<=(L+L3);x++)
{
sf=((L-x)/L2);
bm=((L-(L-x)/L2))*(L-sec);
printf("\nat interval x=%d\t sf=0\t bm=0",x);
}
}
if(sec>L)
{
for(x=0;x<sec;x++)
{
printf("\nat interval x=%d\t sf=0\t bm=0",x);
}
for(x=sec;x<=(L+L3);x++)
{
printf("at intervalx=%d\t sf=1\t bm=%d",x,bm=(1+L3-sec));
}
}
getch();
}

20/*Write a program to print REVERSE of a given number: */

#include<stdio.h>
#include<conio.h>
void main()
{
long int no,rem,total=0;
clrscr();
printf("enter the value of no: ");
scanf("%ld",&no);
while(no>0)
{
rem=no%10;
total=(total*10)+rem;
no=no/10;
}
printf("the reverse of no is
getch();

%ld",total);

21/*write a program to place the given nos into ascending and


descending order*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,n,temp,no[20];
clrscr();
printf("enter no of values:");
scanf("%d",&n);
printf("enter values:\n");
for(i=1;i<=n;i++)
{
scanf("%d",&no[i]);
}
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if(no[j-1]>no[j])
{
temp=no[j-1];
no[j-1]=no[j];
no[j]=temp;

}
}
}
printf("\nascending order:");
for(j=0;j<n;j++)
{
printf("\n\t%d",no[j]);
}
printf("\ndescending order:");
for(i=n-1;i>=0;i--)
{
printf("\n\t%d",no[i]);
}
getch();
}

22/*write a program to generate sin series */


#include<stdio.h>
#include<math.h>
#include<conio.h>
main()
{
long double power(float x,float b),fact(float b),sum=0.0;
float xd,x,i,a,b,pi=3.142857;
clrscr();
printf("enter the value of x in degree:");
scanf("%f",&xd);
x=xd*pi/180.0;
for(i=1.0;i<=10.0;i++)
{
a=2.0*i-1.0;
b=2.0*i;
sum=sum+((pow(x,a))/fact(a))-((pow(x,b))/fact(b));
}
printf("the sin of value x is:%f",sum);
getch();
}
long double power(float x,float b)
{
long double p=1.0,i;
for(i=1.0;i<=b;i++)
{

p=p*x;
}
return(p);
}
long double fact(float b)
{
long double f=1.0,i;
for(i=1.0;i<=b;i++)
{
f=f*i;
}
return(f);
}

Вам также может понравиться