#define PI=3.14 #define div=100 void main() { int gd= DETECT,gm,p,q,z,i,n; float alfa, alfa1,zi,fi,m,R,Ra,Rb,Rr,S,x,y,w,theta; float x1,y1,y2,x2,y3,x3,x4,y4,x5,y5,x6,y6; printf("enter module, no. of teeth,pressure angle in rad"); scanf("%f %d %f",&n,&z,&f); alfa = PI; p=200; q=250; zi=tan(fi)-fi; R=m*z/2; Ra=R+m; Rb=R*cos(fi); Rr=R-1.157*m; theta=sqrt(Ra*Ra-Rb*Rb)/(Rb*div); int graph (p,q,Rr); circle(p,q,R); for(i=0;i
Faculty: Nitin Jauhari, Assoc. Prof-ME Deptt, IPEC
MD-2 Lab NME-652 C++ Programs alfa=(alfa-(PI/z+2*z)); for(n=0;n #include void main() { float fa=0,fr=0,Co=0,e=0,X=0,Y=0,P=0,l=0,n,C=0,a; int v; clrscr(); printf("Enter Fa,Fr,Co:"); scanf("%f%f%f",&fa,&fr,&Co); if((fa/Co>=0.025&&fa/Co<=0.040)||fa/Co<=0.025) { e=(((0.24-0.22)/(0.040-0.025))*((fa/Co)-0.025))+0.22; } 5
Faculty: Nitin Jauhari, Assoc. Prof-ME Deptt, IPEC
MD-2 Lab NME-652 C++ Programs else if(fa/Co>=0.040&&fa/Co<=0.070) e=(((0.27-0.24)/(0.070-0.040))*((fa/Co)-0.040))+0.24; else if(fa/Co>=0.070&&fa/Co<=0.130) e=(((0.31-0.27)/(0.130-0.070))*((fa/Co)-0.070))+0.27; else if(fa/Co>=0.130&&fa/Co<=0.250) e=(((0.37-0.31)/(0.250-0.130))*((fa/Co)-0.130))+0.31; else if((fa/Co>=0.250&&fa/Co<=0.500)||fa/Co>=0.500) e=(((0.44-0.37)/(0.500-0.250))*((fa/Co)-0.250))+0.37; else printf("invalid input"); if(fa/fr<=e) {X=1; Y=0; } else {X=0.56; if((fa/Co>=0.025&&fa/Co<=0.040)||fa/Co<=0.025) Y=(((1.8-2.0)/(0.040-0.025))*((fa/Co)-0.025))+2.0; else if(fa/Co>=0.040&&fa/Co<=0.070) Y=(((1.6-1.8)/(0.070-0.040))*((fa/Co)-0.040))+1.8; else if(fa/Co>=0.070&&fa/Co<=0.130) Y=(((1.4-1.6)/(0.130-0.070))*((fa/Co)-0.070))+1.6; else if(fa/Co>=0.130&&fa/Co<=0.250) Y=(((1.2-1.4)/(0.250-0.130))*((fa/Co)-0.130))+1.4; else if((fa/Co>=0.250&&fa/Co<=0.500)||fa/Co>=0.500) Y=(((1.0-1.2)/(0.500-0.250))*((fa/Co)-0.250))+1.2; } P=X*fr+Y*fa; printf("Enter the value of L10:"); scanf("%f",&l); printf("For ball bearing press 1 and for roller bearing press 2:"); scanf("%d",&v); if(v==1) n=0.333333; else if(v==2) n=0.3; else printf("Invalid input"); a=pow(l,n); C=P*a; printf("Value of equivalent dynamic load: %f",P); 6
Faculty: Nitin Jauhari, Assoc. Prof-ME Deptt, IPEC
MD-2 Lab NME-652 C++ Programs printf("\nValue of dynamic load capacity is: %f",C); getch(); } 4. Program to Design a shaft #include #include #define PI=3.14 void main() { int i,rpm; float p,t,x,fs,w,bm,fb; printf("for design by torsion press /n"); printf("for design by bm press 2/n"); printf("for design by torque t and bm press 3/n"); scanf("%d",&i); switch { case1; printf("enter the value of power to be transmitted by the shaft and its rpm"); scanf"%f%d",&p&rpm); t=(p*60)/(2*PI*rpm); printf("enter the value of allowable shear stress for the material"); scanf("%f",&fs); ds=pow(x,0.333) printf("diameter of shaft=%F",ds); break; case2; printf("enter the value of load"); scanf("%f",&w); printf("enter the length of shaft"); scanf("%d",&l); bm=w*l; printf("enter max. bending stress "); scanf("%d",&fb); x=(bm*32)/PI*fb; ds=-pow(x,0.333); printf("diameter of shaft = %f",ds); } getch(); clrscr();} 7
Faculty: Nitin Jauhari, Assoc. Prof-ME Deptt, IPEC
MD-2 Lab NME-652 C++ Programs 5. Program to determine torque on a shaft #include #include #define PI=3.14 float torque(float d,float f); void main() { float T,D,fs; printf("/n enter the value of diameter in cm"); scanf("%f",&D); printf("/n enter max. allowed shear stress N/mm^2"); scanf("f",fs); T=torque (D,fs); printf("/n torque = %f",T); } float torque (float d, float f); { float t; t=(PI/16)*d*d*d*f; return(t); getch(); clrscr(); }
C: Mini – Project ( To be given Later)
8