#include stdio.h
#include stdlib.h
float P, V, n, R, T;
float PressaoGas(float n, float R, float T, float V) {
P = ((n*R*T)/V);
return(P);
}
float MolsGas(float P, float R, float T, float V) {
n = ((P*V)/(R*T));
return(n);
}
float TemperaturaGas(float P, float V, float n, float R) {
T = ((P*V)/(n*R));
return(T);
}
float ConstanteGas(float P, float V, float n, float T) {
R = ((P*V)/(n*T));
return(R);
}
float VolumeGas(float P, float n, float R, float T) {
V = ((n*R*T)/P);
return(V);
}
main() {
int op, rep;
rep = 1;
while(rep == 1) {
printf("\n\t\t\tEQUACAO DOS GASES IDEAIS\n");
printf("\n\tMenu:\n\t=====\n");
printf("\t1- P\n");
printf("\t2- V\n");
printf("\t3- n\n");
printf("\t4- R\n");
printf("\t5- T\n");
printf("\n\tOpcao.: ");
scanf("%d", &op);
printf("\n\t================================================================\n");
switch(op) {
case 1:
printf("\n\tDigite o volume.........: ");
scanf("%f", &V);
printf("\tDigite o numero de mols.: ");
scanf("%f", &n);
printf("\tDigite a constante R....: ");
scanf("%f", &R);
printf("\tDigite a temperatura....: ");
scanf("%f", &T);
printf("\n\tA pressao = %f\n", PressaoGas(V, n, R, T));
break;
case 2:
printf("\n\tDigite a pressao........: ");
scanf("%f", &P);
printf("\tDigite o numero de mols.: ");
scanf("%f", &n);
printf("\tDigite a constante R....: ");
scanf("%f", &R);
printf("\tDigite a temperatura....: ");
scanf("%f", &T);
printf("\n\tO volume = %f\n", VolumeGas(P, n, R, T));
break;
case 3:
printf("\n\tDigite a pressao........: ");
scanf("%f", &P);
printf("\tDigite o volume.........: ");
scanf("%f", &V);
printf("\tDigite a constante R....: ");
scanf("%f", &R);
printf("\tDigite a temperatura....: ");
scanf("%f", &T);
printf("\n\tO numero de mols = %f\n", MolsGas(P, V, R, T));
break;
case 4:
printf("\n\tDigite a pressao........: ");
scanf("%f", &P);
printf("\tDigite o volume.........: ");
scanf("%f", &V);
printf("\tDigite o numero de mols.: ");
scanf("%f", &n);
printf("\tDigite a temperatura....: ");
scanf("%f", &T);
printf("\n\tA constante R = %f\n", ConstanteGas(P, V, n, T));
break;
case 5:
printf("\n\tDigite a pressao........: ");
scanf("%f", &P);
printf("\tDigite o volume.........: ");
scanf("%f", &V);
printf("\tDigite o numero de mols.: ");
scanf("%f", &n);
printf("\tDigite a constante R....: ");
scanf("%f", &R);
printf("\n\tA temperatura = %f\n", TemperaturaGas(P, V, n, R));
break;
default:
printf("\n\tOpcao inexistente!\n");
break;
}
printf("\n\t================================================================\n");
printf("\n\tContinuar usando o programa?\n\n\t1-Sim 2-Nao\n\n\tOpcao.: ");
scanf("%d", &rep);
system("clear");
}
return(0);
}