A: (Computer & Language) 1. Program to Convert Temperature from Fahrenheit to Cesius #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(); } 2. 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; }} 1
Faculty: Nitin Jauhari,
Assoc. Prof-ME Deptt, IPEC
MD-2 Lab NME-652 C++ Programs
3. 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(); } 4. 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(); } 5. 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++) 2
printf("\nValue of dynamic load capacity is: %f",C); getch(); } 4. Program to Design a 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 { 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<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/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 Programming, Design A Spring (Helical) Under Given Static and Fluctuating Load For A Given Spring Index So That The Spring Design Lie Within Safe Limit.