Programming Tutorials

Comment on Tutorial - Using switch Statements in C++ By Emiley J



Comment Added by : shah

Comment Added at : 2011-02-07 01:11:12

Comment on Tutorial : Using switch Statements in C++ By Emiley J
I want inserted switch statement in my program,
Really need your help and comment.. Thank you..

#include <stdio.h>
#include<conio.h>
#include <math.h>

Main () /*calculate maximun stress */
{

float P, L, w, t;

printf("\t\t\n\n\n <<<This program is to calculate maximum stress>>>\t\n\n\n");
printf("Please input force value, P [KN]: ");
scanf("%f" , &P);
printf("Please input length, L [m]: ");
scanf("%f" , &L);
printf("Please input width, w [cm]: ");
scanf("%f" , &w);
printf("Please input thickness, t [cm]: ");
scanf("%f" , &t);


/* calculate M, y, I */

float M, y, I, max ;

/* convertion */
float w_m, t_m, P_N;
t_m = t /100;
w_m = w /100;
P_N = P * 1000;

/* calculation */

M = P_N * L;
y = t_m /2;
I = (w_m * pow(t_m,3 )) /12 ;
max = (M * y)/ I ;

/* Result */

printf("\n The maximun stress is = %8.3e[pa] or %8.2f[Mpa] \n ", max , max/10000000 );
getch();
system("PAUSE");

}

from..shah


View Tutorial