Anda di halaman 1dari 13

Index

Sr. No. Program Page Signature


Write a program to Convert Temperature
01 02
from Fahrenheit to Celsius.

Write a program to Find the Factorial of


02 03
a Number.

Write a program to Find the sum of N


03 04
integers.

Write a program to determine whether a


04 05
year is leap.

Write a program to determine elements


05 06
of Fibonacci Series

Write a program to determine the


06 07
dimensions of Spur Gear.

Write a program to determine involute


07 08
profile of gear.

08 Write a program for design of roller 10


bearing.
09 Write a program for the design of shaft. 12

Write a program to determine torque on


10 13
a shaft.

1
Experiment No.: 01
Program 1: Write a program to Convert Temperature from Fahrenheit to Celsius.

#include<stdio.h>
#include<conio.h>
void main()
{
float c,f;
printf("enter the temperature in fahrenheit");
scanf("%f",&f);
c=5.0/9.0*(f-32.0);
printf("the temperature in celius is %f",c);
getch();
clrscr();
}

Output:
enter the temperature in Fahrenheit 200
the temperature in Celsius is 93.33

2
Experiment No.: 02
Program 2: Write a program to Find the Factorial of a Number.

#include<stdio.h>
#include<conio.h>
int fact(int);
void main()
{
int i,n; clrscr();
printf("Enter the number for factorial:\t");
scanf("%d",&n);
i=fact(n);
printf("The factorial of %d is %d",n,i);
getch();
}
int fact(int n)
{
int c; if(n==0) return 1; else
if(n==1) return 1; else {
c=n*fact(n-1); return c;
}
}

Output:
Enter the number for factorial: 5
The factorial of 5 is 120

3
Experiment No.: 03
Program 3: Write a program to Find the sum of N integers.

#include<stdio.h>
#include<conio.h>
void main ()
{
float n,sum;
printf ("enter the value of integer");
scanf("%f",&n);
sum=n*(n+1)/2;
printf("\n\n the sum of no from 1 to %f is %f\n",n,sum);
getch();
}

Output:
enter the value of integer 10
the sum of no from 1 to 10 is 55

4
Experiment No.: 04
Program 4: Write a program to determine whether a year is leap.

#include<stdio.h>
#include<conio.h>
void main()
{
int YEAR;
printf ("ENTER THE YEAR:");
scanf ("%d", & YEAR);
if(YEAR %4==0 && YEAR %100!=0 || YEAR %400==0)
printf("n\n\%d is a LEAP YEAR\n ",YEAR);
else
printf("\n\n%d is not a leap year\n", YEAR);
getch();
clrscr();
}

Output:
ENTER THE YEAR 2016
2016 is a LEAP YEAR

5
Experiment No.: 05
Program 5: Write a program to determine elements of Fibonacci Series.

#include<stdio.h>
#include<conio.h>
int fib(int);
void main()
{
int i,n;
clrscr();
printf("Enter the number for fibonacci series:\t");
scanf("%d",&n);
printf("The fibonacci series is :\n");
for(i=1;i<=n;i++)
{
printf("%d\t",fib(i));
}
getch();
}
int fib(int n)
{
if(n==1)
{
return 0;
}
else if(n==2)
{
return 1;
}
else
return(fib(n-1)+fib(n-2));
}

Output:
Enter the number for fibonacci series: 8
The fibonacci series is :
0 1 1 2 3 5 8 13

6
Experiment No.: 06
Program 6: Write a program to determine the dimensions of Spur Gear.

#include<stdio.h>
#include<conio.h>
void main()
{
int zp,zg,m;
float cd,dp,dg,ha,hd,t,c,g;
clrscr();
printf("Enter the number of teeth on pinion and gear ");
scanf("%d %d",&zp,&zg);
printf("enter module ");
scanf("%d",&m);
cd=m*(zp+zg)/2;
dp=m*zp;
dg=m*zg;
ha=m;
hd=1.25*m;
t=1.5708*m;
c=0.025*m;
g=zg/zp;
printf("\n centre distance %f',cd);
printf("\n PCD of pinion and gear %f %f",dp,dg);
printf("\n addendum and dedendum %f %f",ha,hd);
printf("\n tooth thickness %f,t);
printf("\n gear ratio %f',g);
printf("\n clearance %f",c);
getch();
}

Output:
Enter the number of teeth on pinion and gear 40 20
enter module 5
centre distance 150.00
PCD of pinion and gear 200.00 100.00
addendum and dedendum 5.00 6.25
tooth thickness 7.84
gear ratio 0.5
clearance 0.125

7
Experiment No.: 07
Program 7: Write a program to determine involute profile of gear.

#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<graphics.h>
#include<stdlib.h>
#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<z;i++)
(
for(n=0;n<div;n++)
{
w=Rb*n*theta;
r=p+Rb*cos(alfa-n*theta);
s=q+Rb*sin(alfa-n*theta);
x=r-w*sin(alfa-n*theta);
y=s+w*cos(alfa-n*theta);
put pixal(x,y,15);
}
x1=x; y1=y;
alfa=(alfa-(PI/z+2*z));
for(n=0;n<div;n++)
{
w=Rb*n*theta; r=p+Rb*cos(alfa1+n*theta); s=q+Rb*sin(alfa 1 +n*theta);
x=r+w*sin(alfa 1 +n*theta); y=s-w*cos(alfa1+n*theta); put pixal(x,y,14);
8
}
x2=x; y2=y;
line(x1,y1,x2,y2);
x3=p+Rb*cos(alfa);
y3=q+Rb*sin(alfa);
x4=P+Rr*sin(alfa);
y4=q+Rr*sin(alfa);
x5=p+Rb*cos(alfa);
y5=q+Rb*sin(alfa);
y6=q+Rr*sin(alfa);
line(x3,y3,x4,y4);
line(x5,y5,x6,y6);
alfa=alfa-2*PI/z;
}
getch();
close graph();
}

9
Experiment No.: 08
Program 8: Write a program for design of roller bearing.

#include<math.h>
#include<conio.h>
#include<stdio.h>
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;
}
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)

10
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);
printf("\nValue of dynamic load capacity is: %f',C);
getch();
}

Output

Enter Fa,fr,Co 3000 8000 72000


Enter the value of L10: 1440
For ball bearing press 1 and for roller bearing press 2: 1
Value of equivalent dynamic load: 9846.666992
Value of dynamic load capacity is 111192.546875

11
Experiment No.: 09
Program 9: Write a program for the design of shaft.

#include<stdio.h>
#include<conio.h>
#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
{
casel;
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();
}

12
Experiment No.: 10
Program 10: Write a program to determine torque on a shaft.

#include<stdio.h>
#include<conio.h>
#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/mmA2"); 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();
}

13

Anda mungkin juga menyukai