Thursday, June 2, 2011

TO CHECK LCR CIRCUIT

0 comments
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int R;
float L,C,a,b,r;
printf("Enter the resistance in ohm\n");
scanf("%d",&R);
printf("Enter the inductance in Henry\n");
scanf("%f",&L);
printf("Enter the capacitance in Farad\n");
scanf("%f",&C);
a=(R*R)/(4*L*L);
b=1/(L*C);
if(a==b)
printf("The LCR circuit is critically damped");
else
{
if(a>b)
printf("The LCR circuit is over damped");
else
{
printf("The LCR circuit is under damped");
r=a-b;
w=sqrt(r);
printf("The frequency of oscillation is %f",w);
}
}
getch();
}






Algorithm:


1.start
2.Read resistance in ohms,R
3.Read inductance in henry,L
4.Read capacitance in farad,C
5.Calculate 
a=(R*R)/(4*L*L)
b=1/(L*C)
6.If a=b,print LCR circuit is critically damped
7.If a>b,print LCR circuit is over damped
8.If a<b,print LCR circuit is under damped
9.Calculate 
r=a-b
w=sqrt(r)
10.print frequency of oscillation
11.Stop
Continue reading →

TO FIND ANGULAR MOMENTUM OF A ROTATING BODY

0 comments
#include<stdio.h>
#include<stdio.h>
#include<stdio.h>
void main()
{
int a1,a2,a3,p1,p2,p3,l1,l2,l3;
printf("Enter the componetns of distance from axis of rotation");
scanf("%d%d%d",&a1,&a2,&a3);
Printf("\nEnter the components of linear momentum");
scanf("%d%d%d",&p1,&p2,&p3);
l1=a2*p3-a3*p2;
l2=a3*p1-a1*p3;
l3=a1*p2-p1*a2;
printf("The angular momentum vector is given by %di+%dj+%dk",l1,l2,l3);
getch();
}






Algorith:


1.Start
2.Read component of distance from axis of rotation a1,a2,a3
3.Read the components of angular momentum p1,p2,p3
4.calculate
 l1=a2*p3-a3*p2;
l2=a3*p1-a1*p3;
l3=a1*p2-p1*a2;
5.Print the angular momentum l1i+l2j+l3k
6.Stop


Continue reading →

TO FIND WORK DONE BY A FORCE

0 comments
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a1,a2,a3,f1,f2,f3,w;
printf("Enter the coefficients of force");
scanf("%d%d%d",&f1,&f2&f3);
clrscr();
printf("Enter the components of displacement\n");
scanf("%d%d%d",&a1,&a2,&a3);
w=a1*f1+a2*f2+a3*f3;
printf("Work done by the force is %d",w);
getch();
}






Algorithm:


1.Start
2.Read components of force,f1,f2,f3
3.Read components of displacement a1,a2,a3
4.Calculate the work done w=a1*f1+a2*f2+a3*f3
5.print work done
6.stop
Continue reading →

Algorithm of Matrix multiplication

0 comments
1.Start
2.If(n not equal to p) goto step3 else goto step4
3.Print "Matrices not compatible" goto step36
4.If(n=p) goto step5 else goto step11
5.Assign i=1
6.If i<=n then i=1 and goto7 else goto11
7.If j<=n then goto8 else goto10
8.Read a[i][j]
9.Assign j=j+1 goto step7
10.Assign i=i+1 goto step6
11.Assign i=1
12.If i<=p then j=1 and goto 13 else goto14
13.If j<=q then goto12 else goto16
14.Read b[i][j]
15.Assign j=j+1 goto step13
16.Assign i=i+1 goto step12
17.Print "The product of two matrices A anb B are "
18.Assign i=1
19.If i<=m then j=1 and goto step20 else goto step24
20.If j<=q then k=1 and goto step21 else goto step23
21.Assign c[i][j]=0,if k<=n and k=k+1 goto step21 else goto22
22.j=j+1 goto step20
23.i=i+1 goto step19
24.Assign i=1
25.If i<=n then j=1 and goto26 else goto31
26.If j<=q then k=1 and goto27 else goto30
27.If k<=n then assign c[i][j]=a[i][j]*b[i][j]
28.k=k+1 goto step27
29.j=j+1 goto step26
30.i=i+1 and goto step25
31.Assign i=1
32.If i<=n,i=1 and goto33 else goto32
33.If j<=q goto step34 else goto35
34.Print c[i][j],j=j+1 and goto step33
35.i=i+1 goto step32
36.stop
Continue reading →