PRESENTACION EN PREZI
#include <iostream>
// DECLARACION DE VARIABLES PUBLICAS Y FUNCIONES
const float pi=3.1415, k=900000*10000, s=8.314472;
int a=0,b=0,c=0,d=0,e=0,;
float r,g,h;
float carga_electrica (int,int);
float fuerza_cargas(int,int,int);
float modulo_young(int,int,float,float);
float frecuencia_oscilacion(int,float);
float choque_inelastico(int, int,int,int);
float presion_gas(int,int,int);
float cantidad_calor(int,int,int,int);
float campo_electricov(int,int);
float campo_electricoe(int,int);
float calculo_viscosidad(int,int,int,int);
using namespace std;
int main()
{
int op;
float l, per, ar;
do
{
cout << endl << "Formulas fisicas con funciones" << endl << endl;
cout << "1. Carga electrica" << endl;
cout << "2. Fuerza entre 2 cargas" << endl;
cout << "3. Modulo de Young" << endl;
cout << "4. Frecuencia de oscilacion" << endl;
cout << "5. Choque inelastico" << endl;
cout << "6. Presion de un gas" << endl;
cout << "7. Cantidad de calor" << endl;
cout << "8. Campo electrico vectorialmente" << endl;
cout << "9. Campo electrico escalarmente" << endl;
cout << "10. Viscosidad" << endl;
cout << "0. Finalizar" << endl << endl;
cout << "Introduzca la opcion elegida: ";
cin >> op;
if ( op != 0 )
{
do
{
} while ( l<0 );
switch (op)
{
case 1:
{
cout<<"calculo carga electrica\n\n";
cout<<"ingresar el numero electron n= ";cin>>a;
cout<<"ingresar el numero entero e= ";cin>>b;
r = carga_electrica(a,b);
cout<<"La carga electrica es = "<<r<<"\n\n";
system("PAUSE");
break;
}
break;
case 2:
{
cout<<"calculo de la fuerza entre dos cargas\n\n";
cout<<"ingresar carga 1= ";cin>>a;
cout<<"ingresar carga 2= ";cin>>b;
cout<<"ingresar radio = ";cin>>c;
r = fuerza_cargas(a,b,c);
cout<<"La fuerza es = "<<r<<"\n\n";
system("PAUSE");
break;
}
case 3:
{
cout<<"calculo de modulo de young\n\n";
cout<<"ingresar fuerza = ";cin>>a;
cout<<"ingresar area = ";cin>>b;
cout<<"ingresar variacion = ";cin>>c;
cout<<"ingresar longitud = ";cin>>d;
r = modulo_young(a,b,c,d);
cout<<"El modulo de young es = "<<r<<"\n\n";
system("PAUSE");
break;
}
case 4:
{
cout<<"calculo de frecuencia de oscilacion\n\n";
cout<<"ingresar masa = ";cin>>a;
cout<<"ingresar el constante elastico = ";cin>>g;
r = frecuencia_oscilacion(a,g);
cout<<"La frecuencia de oscilacion es = "<<r<<"\n\n";
system("PAUSE");
break;
}
case 5:
{
cout<<"calculo de choque inelastico\n";
cout<<"ingresar la masa 1 = ";cin>>a;
cout<<"ingresar la masa 2 = ";cin>>b;
cout<<"ingresar la velocidad 1 = ";cin>>c;
cout<<"ingresar la velocidad 2 = ";cin>>d;
r = choque_inelastico(a,b,c,d);
cout<<"La velocidad final es = "<<r<<"\n\n";
system("PAUSE");
break;
}
case 6:
{
cout<<"calculo de la presion de un gas\n";
cout<<"ingresar volumen = ";cin>>a;
cout<<"ingresar temperatura = ";cin>>b;
cout<<"ingresar numero de moles = ";cin>>c;
r = presion_gas(a,b,c);
cout<<"La presion es = "<<r<<"\n\n";
system("PAUSE");
break;
}
case 7:
{
cout<<"Calculo de la cantidad de calor \n";
cout<<"ingresar temperatura 1 = ";cin>>a;
cout<<"ingresar temperatura 2 = ";cin>>b;
cout<<"ingresar masa = ";cin>>c;
cout<<"ingresar calor especifico = ";cin>>d;
r = cantidad_calor(a,b,c,d);
cout<<"resultado de cantidad de calor = "<<r<<"\n\n";
system("PAUSE");
break;
}
case 8:
{
cout<<"calculo campo electrico vectorialmente\n";
cout<<"ingresar carga puntual = ";cin>>a;
cout<<"ingresar fuerza = ";cin>>b;
r = campo_electricov(a,b);
cout<<"El campo electrico vectorial es = "<<r<<"\n\n";
system("PAUSE");
break;
}
case 9:
{
cout<<"calculo campo electrico escalar\n";
cout<<"ingresar carga puntual = ";cin>>a;
cout<<"ingresar distancia = ";cin>>b;
r = campo_electricoe(a,b);
cout<<"El campo electrico escalar es = "<<r<<"\n\n";
system("PAUSE");
break;
}
case 10:
{
cout<<"calculo viscosidad\n";
cout<<"ingresar area = ";cin>>a;
cout<<"ingresar coef. viscosidad = ";cin>>b;
cout<<"ingresar velocidad = ";cin>>d;
cout<<"ingresar altura = ";cin>>c;
r = calculo_viscosidad(a,b,d,c);
cout<<"La viscosidad es = "<<r<<"\n\n";
system("PAUSE");
break;
}
defaul:
cout << endl << "Opcion no valida" << endl;
break;
}
}
// FIN DEL PRIMER BUCLE
} while ( op != 0 );
cout << endl << "Gracias por utilizar el programa" << endl;
system ("read");
return 0;
// FIN DEL CUERPO PRINCIPAL DEL PROGRAMA
}
// ZONA DE DESARROLLO DE FUNCIONES
float carga_electrica(int a,int b)
{
return a*b;
}
float fuerza_cargas(int a,int b, int c)
{
return k*((a*b)/c);
}
float modulo_young(int a,int b,float c,float d)
{
return ((a*d)/(b*c));
}
float frecuencia_oscilacion(int a,float g)
{
return (a/g)*2*pi;
}
float choque_inelastico(int a,int b,int c,int d)
{
return a*c+b*d/a+b;
}
float presion_gas(int a,int b,int c)
{
return c*s*b/a;
}
float cantidad_calor(int a,int b,int c,int d)
{
return d*c*(b-a);
}
float campo_electricov(int a,int b)
{
return b/a;
}
float campo_electricoe(int a,int b)
{
return k*a/b*b;
}
float calculo_viscosidad(int a,int b,int c,int d)
{
return b*a*d/c;
}
viernes, 28 de junio de 2013
domingo, 9 de junio de 2013
For, While y Do While
#include <iostream>
using namespace std;
// VARIABLES PUBLICAS
int opcion,n,i,v;
int main ()
{
// TOMA D DECISION MUILTIPLE
// INICIO DEL BUBLE DO WHILE
do
{
cout<<"---------------------";
cout<<"MENU PRINCIPAL \n \n";
cout<<"1) CALCULO DE LA CARGA ELECTRICA \n";
cout<<"2) CALCULO DEL VOLTAJE \n";
cout<<"3) CALCULO DE LA POTENCIA ELECTRICA \n";
cout<<" INGRESE UNA OPCION /<0> PARA SALIR \n\n"; cin>>opcion;
switch (opcion)
{
case 1:
{
double r;
int final;
cout<<"--------------------------------------------------------------\n";
cout << "CALCULO DE LA CARGA ELECTRICA\n\n" << "";
cout << "INGRESE LA INTENSIDAD: "; cin>>final;
cout << "INGRESE EL TIEMPO: "; cin>>v;
for (n=1; n<=final; n++)
{
r = n * v;
cout << r << "\n ";
++i;
}
cout << "FIN\n";
}
break;
case 2:
{
double s;
int final;
cout << "\n\n";
cout << "-------------------------------------------------------------\n";
cout << "CALCULO DEL VOLTAJE \n\n";
cout << "INGRESE LA INTENSIDAD DE CORRIENTE > ";cin >> final;
cout << "INGRESE LA RESISTENCIA: "; cin>>v;
i=1;
while (i<=final)
{
s = i*v;
cout << s << "\n ";
++i;
}
cout << "FIN\n";
}
break;
case 3:
{
// CALCULO DE LOS NUMEROS PARES
cout << "\n\n";
cout << "------------------------------------------------------------\n";
cout << "CALCULO DE LA POTENCIA ELECTRICA \n\n";
i=1;
cout << "INGRESE LA RESISTENCIA: ";cin >> n;
cout << "INGRESE LA INTENSIDAD DE CORRIENTE: ";cin >> v;
do
{
cout << i*(v*v) <<"\n";
i++;
} while (i<=n);
break;
}
default:
cout<<"grupo default de instrucciones \n";
}
// FIN DEL BUBLE WHILE
} while (opcion!=0);
// FINAL DEL PROGRAMA
system("pause");
return 0;
}
using namespace std;
// VARIABLES PUBLICAS
int opcion,n,i,v;
int main ()
{
// TOMA D DECISION MUILTIPLE
// INICIO DEL BUBLE DO WHILE
do
{
cout<<"---------------------";
cout<<"MENU PRINCIPAL \n \n";
cout<<"1) CALCULO DE LA CARGA ELECTRICA \n";
cout<<"2) CALCULO DEL VOLTAJE \n";
cout<<"3) CALCULO DE LA POTENCIA ELECTRICA \n";
cout<<" INGRESE UNA OPCION /<0> PARA SALIR \n\n"; cin>>opcion;
switch (opcion)
{
case 1:
{
double r;
int final;
cout<<"--------------------------------------------------------------\n";
cout << "CALCULO DE LA CARGA ELECTRICA\n\n" << "";
cout << "INGRESE LA INTENSIDAD: "; cin>>final;
cout << "INGRESE EL TIEMPO: "; cin>>v;
for (n=1; n<=final; n++)
{
r = n * v;
cout << r << "\n ";
++i;
}
cout << "FIN\n";
}
break;
case 2:
{
double s;
int final;
cout << "\n\n";
cout << "-------------------------------------------------------------\n";
cout << "CALCULO DEL VOLTAJE \n\n";
cout << "INGRESE LA INTENSIDAD DE CORRIENTE > ";cin >> final;
cout << "INGRESE LA RESISTENCIA: "; cin>>v;
i=1;
while (i<=final)
{
s = i*v;
cout << s << "\n ";
++i;
}
cout << "FIN\n";
}
break;
case 3:
{
// CALCULO DE LOS NUMEROS PARES
cout << "\n\n";
cout << "------------------------------------------------------------\n";
cout << "CALCULO DE LA POTENCIA ELECTRICA \n\n";
i=1;
cout << "INGRESE LA RESISTENCIA: ";cin >> n;
cout << "INGRESE LA INTENSIDAD DE CORRIENTE: ";cin >> v;
do
{
cout << i*(v*v) <<"\n";
i++;
} while (i<=n);
break;
}
default:
cout<<"grupo default de instrucciones \n";
}
// FIN DEL BUBLE WHILE
} while (opcion!=0);
// FINAL DEL PROGRAMA
system("pause");
return 0;
}
Suscribirse a:
Entradas (Atom)