Professional Documents
Culture Documents
GUWAHATI-13
TOPIC
FINDING THE RESULTANT OF ‘n’NUMBER OF FORCES BY
TAKING INPUT FROM THE USER.
pg.no
1.)PROGRAMME IN TURBO C++ 1
2.)FLOW CHART 2
3.)ALGORITHM 3
4.)OUTPUT SCREEN 4
5.)CONCLUSION 5
PROGRAMME IN TURBO C++ TO FIND THE RESULTANT OF FORCES
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float o[30],rx=0,ry=0,ao,ff,n,f[30],ro[30],fa;
printf("\nEnter the number of forces\n");
scanf("%f",&n);
for(int i=1;i<=n;i++)
{
printf("Enter the force %d:",i);
scanf("%f",&f[i]);
printf("Enter the angle of the force %d:",i);
scanf("%f",&o[i]);
if(o[i]>180)
{
o[i]=o[i]-180;
}
else
{
o[i]=o[i];
}
ro[i]=o[i]*22/(7*180);
rx=rx+f[i]*cos(ro[i]);
ry=ry+f[i]*sin(ro[i]);
}
ff=sqrt(rx*rx+ry*ry);
printf("Resultant force=%f",ff);
ao=atan(ry/rx);
fa=(ao*180*7)/22;
printf("\nAngle of the resultant force making with x-axis =%f",fa);
printf("\nTHANK YOU");
getch();
}
START
} O[30],rx-0,ry=0,ao,ff,n,f[30],ro[30],
Fa,i=1. FLOW
#include<stdio.h>
Entter the forces
CHART
#include<conio.h>
Get the values of
forces
#include<math.h>
void main()
{ i<n
float o[30],rx=0,ry=0,ao,ff,n,f[30],ro[30],fa;
Print the force and
printf("\nEnter theTake
number of forces\n");
the value in f
scanf("%f",&n);
for(int i=1;i<=n;i++)
Print the angle and
take it in o[i].
{
printf("Enter the forceIf%d:",i);
scanf("%f",&f[i]); o[i]>
180
printf("Enter the angle of the force %d:",i);
scanf("%f",&o[i]);
o[i]=o[i]-180 o[i]=o[i]
if(o[i]>180)
{
ro[i]=o[i]*(22/7)*180
o[i]=o[i]-180;
} rx=rx+f[i]*cos(ro[i])
else
{ ry=ry+f[i]*sin(ro[i]) ao=atan(ry/rx)
o[i]=o[i];
ff=sqrt(rx*rx+ry*ry)
} Print the
ro[i]=o[i]*22/(7*180); Value of
ao.
rx=rx+f[i Print the values
Of ff
END
ALGORTHIM OF THE PROGRAMME.
STEP 15:End.
OUTPUT SCREEN
CONCLUSION
Programming language has spreaded its hands to all