LAB 2

DEV-C++

#include<iostream>
#include<math.h>
using namespace std;

int i,c;
int Carga[10],min,suma;
float F;
void ingresar();
void lectura ();
int maximo ();
int minimo();
int sumar();
void ley();


int main()

{
// 1) DECLARACION

int opcion;
do
{
cout<<"\n *******************  MENU PRINCIPAL ********************* \n\n";
cout<<" 1) INGRESAR LAS CARGAS ELECTRICAS \n ";
cout<<"2) IMPRESION DE LA LONGITUD LAS CARGAS ELECTRICAS\n ";
cout<<"3) CARGA MAXIMA \n ";
cout<<"4) CARGA MENOR \n ";
cout<<"5) SUMA DE CARGAS ELECTRICAS \n ";
cout<<"6) FUERZA DE LEY DE OHM PARA CADA ELEMENTO DEL VECTOR \n ";
cout<<" DIGITE <0> PARA SALIR \n\n ";
cout<<"********************************************************* \n\n";
cout<<"      INGRESE UNA OPCION : ";  cin>>opcion;


switch (opcion)
{
 case 1:
{
cout<<" ****** LECTURA DE LONGITUD DEL CONDUCTOR ***********\n";
ingresar ();
cout<<endl;
cout<<" ********************************************************* \n";
}
break;

case 2:
{
cout<<"** IMPRESION O ESCRITURA DE LA LONGITUD DEL CONDUCTOR *****\n";
lectura ();
cout<<endl;
cout<<" ********************************************************* \n";
}
break;

case 3:
{
cout<<"\n ***** PROCESAR LA CARGA MAXIMA *******************\n";
maximo ();
cout<<endl;
cout<<"\n ********************************************************* \n";
}
break;

case 4:
{
cout<<"\n ********** PROCESAR LA MINIMA CARGA *************\n";
minimo();
cout<<endl;
cout<<"\n ********************************************************* \n\n";
}
break;

case 5:
{
cout<<"\n ************ SUMA DE LAS CARGAS **************\n";
sumar();
cout<<endl;
cout<<"\n ********************************************************* \n\n";
}
break;

case 6:
{
//TENIENDO DE DATOS QUE LA VELOCIDAD EQUIVALE A 20, UN CAMPO MAGNETICO DE 50 Y UN ANGULO DE 20 HALLAR LA FUERZA DE OHM PARA CADA VALOR DE LOS VECTORES
cout<<"** FUERZA DE LEY DE OHM PARA CADA ELEMENTO DEL VECTOR***\n";
ley();
cout<<endl;
cout<<"\n ********************************************************* \n";
cout<<endl;  
}
break;

}

}
while (opcion !=0);

cout<<endl; cout<<"\n";
system("pause");
return 0;
} // FIN DEL PROGRAMA

//ZONA DE DESARROLLO

void ingresar ()
{
for (i=1;i<=10;i++)
{
 cout<<" INGRESE LA CARGA ELECTRICA C["<<i<<"]: ";cin>> Carga[i];
}
}

void lectura ()
{
for (i=1;i<=10;i++)
{
cout<<" LA CARGA ELECTRICA C["<<i<<"] ES: "<< Carga[i]<<endl;
}
}

int maximo ()
{
int max=0;
for (i=1;i<=10;i++)
{
if(Carga[i]>max)
max = Carga[i];
}
 cout<<" EL MAXIMO ES : "<<max;
}

int minimo ()
{
int min=100;
for (i=1;i<=10;i++)
{
if(Carga[i]<min)
min = Carga[i];
}
cout<<" EL MINIMO ES : "<<min;
}

int sumar ()
{
int suma =0;
for(i=0;i<=10;i++)
suma=suma+Carga[i];
cout<<" \n ----------------------------------------\n";
cout<<"\n LA SUMA DE LONGITUDES ES:"<<suma<<endl;
}

void ley()
{
int suma =0;
for(i=0;i<=10;i++)
{
F=Carga[i]*50*20*sin(20);
cout<<" LA FUERZA DE OHM PARA C["<<i<<"] ES : "<<F<<endl;
}
}

No hay comentarios:

Publicar un comentario