1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
#include "stdio.h"
#include "stdlib.h"
float momentum(float m , float v){
return m*v;
}
float work (float f , float d){
return f * d;
}
float energy (float m , float v){
return 0.5 *(m * (v*v));
}
int main (void){
puts("\t\t========select the formulla========");
puts("1- Momentum");
puts("2- Work");
puts("3- Energy");
puts("4- Go back");
printf("\n\n\nYour option [ ]\b\b");
int select;
float v1, v2;
char s[100];
fgets(s,100,stdin);
sscanf(s,"%d",&select);
switch (select){
case 1:
system("cls");
puts("Enter mass value : ");
fgets(s,100,stdin);
sscanf(s,"%f",&v1);
puts("Enter velocity : ");
fgets(s,100,stdin);
sscanf(s,"%f",&v2);
printf("Momentum is = %f kg-m/sec\n\n",momentum(v1,v2));
break;
case 2:
system("cls");
puts("Enter force value : ");
fgets(s,100,stdin);
sscanf(s,"%f",&v1);
puts("Enter distance value in meters : ");
fgets(s,100,stdin);
sscanf(s,"%f",&v2);
printf("Work is = %f joule(j)\n\n",work(v1,v2));
break;
case 3:
system("cls");
puts("Enter mass value : ");
fgets(s,100,stdin);
sscanf(s,"%f",&v1);
puts("Enter velocity : ");
fgets(s,100,stdin);
sscanf(s,"%f",&v2);
printf("Energy is = %f joule(j)\n\n",energy(v1,v2));
break;
case 4 :
system ("cls");
puts("========Testahbel enta no back Tshaaah astgfur allah========\n");
puts("press 'y' to exit\n");
fgets(s,100,stdin);
if(s[0] == 'y')
break;
}
system("pause");
return 0;
}
|