EVAP4

#include<iostream>
#include<windows.h>
using namespace std;
int main()
{
    int i,n,suma,opcion;
    cout<<"-----MENU-----\n\n";
    cout<<"1)NUMERO PRIMO\n";
    cout<<"2)CALCULO DE LA SUMA DE LOS MULTIPLOS DE 2\n";
    cout<<"3)MCD\n";
    cout<<"4)FACTORIAL\n";
    cout<<"5)NUMERO MAYOR A 100\n";
    cout<<"6)LA SUMA DE LOS PRIMEROS CUBOS ES\n";    
    cout<<"7)LOS NUMEROS DEL 2 AL 20\n";    
    cout<<"8)CALCULO DE LOS PRIMEROS TERMINOS PARES\n";
    cout<<"9)NUMEROS DE X HASTA Y\n";
    cout<<"DIGITE -0- PARA SALIR\n";
    cout<<"**************************\n";
    cout<<"INGRESE UNA OPCION: ";
cin>>opcion;
cout<<endl;
    switch(opcion)
    {
case 1:
        {
int num,c,res,nc=0;
            cout<<"INTRODUCE UN NUMERO: "; cin>>num;
            for(c=1;c<=num;c++)
            {
res=num%c;
                if(res==0)
                nc++;
                if(nc>2)
                break;
            }
            if(nc==2)
            cout<<"Es primo";
            else
            cout<<"No es primo";
break;
        }
        case 2:
        {
            cout <<"CALCULO DE LA SUMA DE LOS MULTIPLOS DE 2\n\n";
cout <<"INGRESE EL NUMERO TERMINOS A SUMAR:";
cin >>n;
cout<<endl;
suma=0;
i = 1;
while (i<=n)
{
suma = suma + (2*i);
i=i+1;
}
cout<<"LA SUMA DE LOS MULTIPLOS DE 2: "<<suma;
cout<<endl;
            break;
        }
        case 3:
        {
cout<<"MCD\n\n";
int N1,N2,menor,mayor,r;
cout<<"INGRESE PRIMER NUMERO:";
cin>>N1;
cout<<"INGRESE SEGUNDO NUMERO:";
cin>>N2;
if(N1>N2)
{
mayor=N1;
menor=N2;
}
else
{
mayor=N2;
menor=N1;
}
while (menor>0)
{
r=mayor%menor;
mayor=menor;
menor=r;
}
cout<<"El MCD es:"<<mayor;
            break;
        }
        case 4:
        {
cout<<"FACTORIAL\n\n";
int N,i;
int f=1;
do
{
cout<<"INGRESE EL NUMERO:";cin>>N;
cout<<endl;
}
while(N<=0);
for(i=1;i<=N;i++)
f=f*i;
cout<<"SU FACTORIAL ES:"<<f;
   cout<<endl;
            break;
        }
        case 5:
        {
cout<<"NUMERO MAYOR A 100\n\n";
   int num;
cout<<"INGRESE UN NUMERO MAYOR A 6\n\n";
cin>>num;
cout<<endl;
if(num<=100)
{
do
{
cout<<"INGRESE UN NUMERO MAYOR A 6\n\n";
cin>>num;
cout<<endl;
}
while(num<=100);
}
   cout<<"EL NUMERO FUE: "<<num;cout<<endl;
            break;
        }
        case 6:
        {
cout<<"LA SUMA DE LOS PRIMEROS CUBOS ES\n\n";
suma=0;
i = 1;
cout<<"SUMA DE LOS PRIMEROS CUBOS\n\n";
cout<<"INGRESE EL NUMERO TERMINOS A SUMAR: ";
cin>>n;
cout<<endl;
for (i=1; i<=n; i++)
{
suma=suma+(i*i*i);
}
cout <<"LA SUMA DE LOS PRIMEROS CUBOS ES: "<<suma;
cout<<endl;
            break;
        }
        case 7:
        {
cout<<"LOS NUMEROS DEL 2 AL 20\n\n";
int a;
cout<<"Los numero del 2 al 20";
cout<<endl;
for(a=2;a<=20;a=a+2)
{
cout<<a;cout<<endl;
}
            break;

        }
        case 8:
        {
suma=0;
i=1;cout<<endl;
cout<<"CALCULO DE LOS PRIMEROS TERMINOS PARES\n\n";
cout<<"INGRESE NUMEROS DE TERMINOS A SUMAR: ";
cin>>n;cout<<endl;
for(i=1;i<=n;i++)
{
suma=suma+(2*i);
            }
            cout<<"LA SUMA DE LOS NUMEROS PARES ES: "<<suma;
cout<<endl;
            break;
        }
        case 9:
        {
cout<<"NUMEROS DE X HASTA Y\n\n";
int Ni,Nf;
       int i;
       cout<<"NUMEROS COMPRENDIDOS EN UN RANGO\n\n";
            cout<<"INGRESE NUMERO INICIAL:";
cin>>Ni;
cout<<endl;
            cout<<"INGRESE NUMERO FINAL:";
cin>>Nf;
cout<<endl;
            for (i=Ni+1;i<Nf;i++)
            {
cout<<-i;cout<<endl;cout<<endl;
}
break;
        }
        cout<<"NO ES UNA OPCION";
    }
    system("pause");
}
                             
 
 
 

No hay comentarios.:

Publicar un comentario