Calcule_la_suma_de_los_terminos_de_la_serie_FIBONACCI (1).docx

5
/*//Resuelve ax+b = 0 #include<iostream> #include<stdlib.h> #include<time.h> using namespace std; void main(){ srand((unsigned)time (NULL)); float a,b;double x; a=rand()%50; cout<<"a = "<<a; b=rand()%50; cout<<"\t\tb = "<<b; if(a==0) cout<<"\nNo es posible la operacion "; else if(b==0) cout<<"x = 0"; else x= (-1)*b/a; cout<<"\nLa solucion a la Ecuacion es = \a"<<x<<endl; system("pause"); } #include<iostream> #include<conio.h> #include<math.h> #include<stdlib.h> #include<time.h> using namespace std; void main() { srand((unsigned)time(NULL)); int A,B,D; A=rand()%50; B=rand()%50; cout<<"A= "<<A; cout<<"\nB= "<<B; if(A==0) D=0; else if(B==0) cout<<"\nNo es posible"; else if(A==B) cout<<"D = 0"; else

Transcript of Calcule_la_suma_de_los_terminos_de_la_serie_FIBONACCI (1).docx

Page 1: Calcule_la_suma_de_los_terminos_de_la_serie_FIBONACCI (1).docx

/*//Resuelve ax+b = 0#include<iostream>#include<stdlib.h>#include<time.h>using namespace std;

void main(){srand((unsigned)time (NULL));float a,b;double x;a=rand()%50;cout<<"a = "<<a;b=rand()%50;cout<<"\t\tb = "<<b;

if(a==0)cout<<"\nNo es posible la operacion ";

elseif(b==0)

cout<<"x = 0";else

x= (-1)*b/a;cout<<"\nLa solucion a la Ecuacion es = \a"<<x<<endl;system("pause");

}

#include<iostream>#include<conio.h>#include<math.h>#include<stdlib.h>#include<time.h>using namespace std;void main(){

srand((unsigned)time(NULL));int A,B,D;A=rand()%50;B=rand()%50;cout<<"A= "<<A;cout<<"\nB= "<<B;if(A==0)

D=0;else

if(B==0)cout<<"\nNo es posible";

elseif(A==B)

cout<<"D = 0";

else if(A>B)

if(A%B==0)cout<<"\nA ES DIVISIBLE POR B";

elsecout<<"\nA no es divisible por

B";else

//if(B>A)

Page 2: Calcule_la_suma_de_los_terminos_de_la_serie_FIBONACCI (1).docx

if(B%A==0)cout<<"B es Divisible por

A";else

cout<<"\nB no es dividible A"<<endl;system("pause");

}

#include<iostream>#include<stdlib.h>#include<time.h>#include<math.h>using namespace std;void main(){

srand((unsigned)time(NULL));int a,b;char opc;a=rand()%20;cout<<"\nEl Valor de a = "<<a;b= rand()%20;cout<<"\nEl Valor de b = "<<b;cout<<"\n + --> Suma"<<endl

<<" - --> Diferencia"<<endl<<" * --> Producto"<<endl<<" ? --> Cociente"<<endl<<" $ --> Residuo"<<endl<<" ~ --> Potencia"<<endl;

cout<<" \nIngrese su Opcion = ";cin>>opc;switch(opc){case '+': cout<<" Suma a y b "<<(a+b);break;case '-': cout<<"Diferencia de a y b "<<(a-b);break;case '*': cout<<"Producto de a y b = "<<(a*b);break;case '?': cout<<"Division de a entre b ";

if(b>0)cout<<(a/b);

elsecout<<"No es posible la division ";break;

case '$': cout<<"El Residuo es ";if(b>0)

cout<<(a%b);else

cout<<"NO es posible el Residuo";break;case '~': cout<<"a elvado a la b = "<<(powf(a,b));break;default :cout<<"No es una Opcion de las Mostradas ";break;}cout<<endl;system("pause");

}

#include<iostream>#include<stdlib.h>#include<time.h>using namespace std;

Page 3: Calcule_la_suma_de_los_terminos_de_la_serie_FIBONACCI (1).docx

void main(){srand((unsigned)time(NULL));int N,i=1;float S=0;N=rand()%200;cout<<"\nEl Valor de N = "<<N;while(i<=N){

S+=i;i++;

}cout<<"\nLa suma de los primeros N terminos es "<<S<<endl;system("pause");

}

*/#include<iostream>#include<stdlib.h>#include<time.h>#include<math.h>using namespace std;void main(){

srand((unsigned)time(NULL));int N,i=1;double Su=0;char opc;for(;;){system("cls");N=rand()%200;cout<<"\nEl Valor de N = "<<N;while(i<=N){

Su+=1.0/(2*i-1);i++;

}cout<<"\nLa Suma es "<<Su<<endl;cout<<"Desea continuar [S][N] ?";cin>>opc;if(opc =='N')break;}system("pause");

}

/*Calcule la suma de los términos de la serie FIBONACCI cuyos valores se encuentran entre 100 y 10,000.#include<iostream>#include<stdlib.h>using namespace std;void main() { int n1=1,n2=2,n3,suma=0,c1=0; while (n1<=10000) { n3=n1+n2; cout<<"\nn3 "<<n3<<' ';c1=c1+1;if ((n3>=100)&&(n3<=10000)) suma=suma+n3; n1=n2+n3; if ((n1>=100)&&(n1<=10000)) suma=suma+n1; n2=n3+n1;

Page 4: Calcule_la_suma_de_los_terminos_de_la_serie_FIBONACCI (1).docx

if ((n2>=100)&&(n2<=10000)) suma=suma+n2; } cout<<"SUMATORIA = " <<suma<<endl<<" El Total de elementos = "<<c1<<endl; system("pause"); }

//invierte un numero de varias cifras, halla el mayor, menor cifra y la suma de sus cifras #include<iostream>#include<stdlib.h>using namespace std;void main() {

long N,dg,dM=0,dm=9,sd=0,inverso=0;cout<<"Ingrese un Numero de varias cifras N =";cin>>N;do{

dg=N%10;inverso=inverso*10+dg;sd=sd+dg;if(dg>dM)

dM=dg;if(dg<dm)

dm=dg;N=N/10;

}while(N>0);cout<<"\nEl Numero Invertido "<<inverso<<endl

<<"El digito Mayor "<<dM<<endl<<"El digito menor "<<dm<<endl<<"La suma de sus cifras es "<<sd<<endl;

system("pause");}

*///Hallar la suma de la suma de la serie 1+1/2!+1/3!+...#include<iostream>#include<stdlib.h>#define mensaje "\Otra Prueba [S][N]"using namespace std;void main() {

long double N,F=1,i=1;double Su=1;char rp;for(;;){cout<<"Ingrse el n umero de terminos N =";cin>>N;while(i<=N){F=F*i;

cout<<"El Factorial de "<<i<<" es "<<F<<endl;Su=Su+1.0/F;

i++;}cout<<"\n La suma es "<<Su<<endl

<<mensaje;cin>>rp;if(rp=='N')break;}system("cls");//system("pause");

Page 5: Calcule_la_suma_de_los_terminos_de_la_serie_FIBONACCI (1).docx

}