Академический Документы
Профессиональный Документы
Культура Документы
/*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();
}
4
8
12
16
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);
}
2
5
8
3
6
9
30
66
102
36
42
81
96
126 150
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
#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
//
{
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();
}
else if (ic==4)
le=2.0*l;
pcr=PI*PI*e*i/(le*le);
printf("\nEuler's crippling load=%3lf",pcr);
getch();
}
printf("%d",a);
a++; //(here u can print i also,result will be
differ.)
printf("
");
}
printf("\n");
}
getch();
}
#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);
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();
}
15
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();
}
}
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();
}
#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);
}
}
}
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();
}
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);
}