fork download
  1. #include<stdio.h>
  2.  
  3. void main()
  4. {
  5. char c;
  6. double V,n,R,T,P;
  7. printf("Of which terms do you want to perform?\n");
  8. printf("\nList :\n\n1.Pressure(P)\n2.Volume(V)\n3.Number of moles of gas(n)\n");
  9. printf("4.Molar gas constant(R)\n5.Temperature(T)\n");
  10. printf("\nPlease press any number from'1-5' to make a choice");
  11. printf("\nYour choice: ");
  12. scanf("%c",&c);
  13. if(c=='1')
  14. {
  15. R=0.082;
  16. printf("\nO.k. Follow the following instruction:\n");
  17. printf("\nPlease give the value of V(Litre),n,T(K)\n");
  18. scanf("%lf%lf%lf",&V,&n,&T);
  19. P=(n*R*T)/V;
  20. printf("\nYour desired pressure is=%lf atm\n",P);
  21.  
  22. }
  23. else if(c=='2')
  24. {
  25. R=0.082;
  26. printf("\nO.k. Follow the following instruction:\n");
  27. printf("\nPlease give the value of P(atm),n,T(K)\n");
  28. scanf("%lf%lf%lf",&P,&n,&T);
  29. V=(n*R*T)/P;
  30. printf("\nYour desired volume is=%lf litre\n",V);
  31.  
  32. }
  33. else if(c=='3')
  34. {
  35. R=0.082;
  36. printf("\nO.k. Follow the following instruction:\n");
  37. printf("\nPlease give the value of V(Litre),P(atm),T(K)\n");
  38. scanf("%lf%lf%lf",&V,&P,&T);
  39. n=(P*V)/(R*T);
  40. printf("\nYour desired number of moles is=%lf mole\n",n);
  41. }
  42. else if(c=='4')
  43. {
  44. printf("\nO.k. Follow the following instruction:\n");
  45. printf("\nPlease give the value of V(Litre),P(atm),n,T(K)\n");
  46. scanf("%lf%lf%lf%lf",&V,&P,&n,&T);
  47. R=(P*V)/(n*T);
  48. printf("\nYour desired molar gas constant is=%lf Latm/Kmol\n",R);
  49. }
  50. else if(c=='5')
  51. {
  52. R=0.082;
  53. printf("\nO.k. Follow the following instruction:\n");
  54. printf("\nPlease give the value of V(Litre),P(atm),n\n");
  55. scanf("%lf%lf%lf",&V,&P,&n);
  56. T=(P*V)/(R*n);
  57. printf("\nYour desired temperature is=%lf K\n",T);
  58. }
  59. else printf("\nSorry-Invalid choice\n");
  60.  
  61. }
  62.  
Runtime error #stdin #stdout 0s 2172KB
stdin
Standard input is empty
stdout
Of which terms do you want to perform?

List :

1.Pressure(P)
2.Volume(V)
3.Number of moles of gas(n)
4.Molar gas constant(R)
5.Temperature(T)

Please press any number from'1-5' to make a choice
Your choice: 
Sorry-Invalid choice