Escolar Documentos
Profissional Documentos
Cultura Documentos
#include <iostream>
#include <math.h>
int main()
{
int opcion;
do
{
opcion=menu();
switch(opcion)
{
case 1:
cout<<"SUMATORIA DE NUMEROS IMPARES "<<endl;
int n;
cout<<"INGRESE UN NUMERO: "<<endl;
cin>>n;
cout<<"LA SUMATORIA DE LOS N NUMEROS IMPARES ES: "<<sumatoria2((n*2)-
1)<<endl;
mostrarnumero(n);
PROGRAMACIÓN
break;
case 2:
cout<<"SUMATORIA DE POTENCIAS IMPARES"<<endl;
int x,N;
cout << "INGRESE EL VALOR DE N " << endl;
cin>> N;
cout << "INGRESE EL VALOR DE X " << endl;
cin>> x;
cout<< "LA SUMATORIA DE POTENCIAS IMPARES ES:"<< sumatoria(x,N)<<endl;
break;
case 3:
int d;
cout<<"CUADRADO DE UN NUMERO"<<endl;
cout<<"INGRESE UN NUMER0"<<endl;
cin>> d;
cout<<"ANTES DE ELEVAR AL CUADRADO "<<d<<endl;
elevar_cuadrado(&d);
cout<<"DESPUES DE ELEVAR AL CUADRADO "<<d<<endl;
break;
case 4:
cout<<"SUMATORIA RECURSIVA"<<endl;
int s,i;
cout<<"INGRESE UN NUMERO"<<endl;
cin>>s;
while (s<0)
{
cout<<"INGRESE UN NUMERO POSITIVO"<<endl;
cin>>s;
}
cout<<" LA SUMA RECURSIVA DE: "<<s<<" ES "<<sumatoria3(s)<<endl;
for (i=1; i<=s; i++)
PROGRAMACIÓN
{
cout<<i<<"+";
}
break;
case 5:
cout<<"CALCULO DE NUMEROS IMPARES "<<endl;
cout<<"INGRESE UN VALOR"<<endl;
cin>>n;
terminosimpares(n);
break;
case 6:
cout<<"CUADRADOS PERFECTOS"<<endl;
int valor;
cout<<"INGRESE UN VALOR"<<endl;
cin>>valor;
while(valor<0)
{
cout<<"NO EXISTE"<<endl;
cout<<" INGRESE UN NUMERO CORRECTO"<<endl;
cin>>valor;
}
cuadradoperfecto(valor);
break;
case 7:
cout<<"SALIR"<<endl;
break;
}
}
while (opcion!=7);
cout<< "GRACIAS";
PROGRAMACIÓN
return 0;
}
int menu()
{
PROGRAMACIÓN
{
cout<<"EL CUADRADO PERFECTO DEL NUMERO ES: "<< i <<endl;
}
result=result-1;
}
}
int sumatoria(int x,int n)
{
int S,impar;
if (n==0)
{
return 0;
}
else
{
impar=(2*n-1)/(2*n-1);
S= x*impar;
}
return S+(sumatoria(x,n-1));
}
void elevar_cuadrado(int *pvalor)
{
*pvalor=(*pvalor)*(*pvalor);
}
void terminosimpares(int n)
{
double i;
float s;
for(i=1; i<n*2; i=i+2)
{
s=(float)(i+2)/10;
PROGRAMACIÓN
cout<<"a"<<i<<"======>"<<s<<endl;
}
}
int sumatoria2(int n)
{
if(n==1)
{
return 1;
}
else
return n+sumatoria2(n-2);
}
void mostrarnumero(int suma)
{
int t;
for(int i=1; i<=2*suma-1; i++)
{
t=i%2;
if(t==1)
cout<<i<<"+";
}
}
int suma;
int sumatoria3 (int a)
{
int result;
if (a==1)
{
result = 1;
}
else
PROGRAMACIÓN
{
return (a + sumatoria3(a-1));
}
}
PROGRAMACIÓN