Vous êtes sur la page 1sur 11

Universidad Mariano Glvez de Retalhuleu Facultad de Ingeniera en Sistemas Ing. Alexis A. Jurez //UMG-REU,ALGORITMOS //Ing.Alexis A. Jurez #include<stdio.

h> main() { int ciclo; printf("este programa imprime los nmeros de 1 al 10 \n"); for(ciclo=1;ciclo<=10;ciclo+=1) printf(" %d \n",ciclo); return 0; }

Universidad Mariano Glvez de Retalhuleu Facultad de Ingeniera en Sistemas Ing. Alexis A. Jurez //UMG-REU, CURSO DE ALGORITMOS /* El PROGRAMA dados N nmeros enteros, obtiene cuantos */ /* de elos son impares y cuantos son pares. */ /*********************************************************/ #include<stdio.h> #include<math.h> main() { int I , N , NUM , CUEPAR , CUEIMP ; CUEPAR = 0; CUEIMP = 0; printf ("\n Ingrese LA CANTIDAD DE NUMEROS : "); scanf ("%d",&N); for ( I = 1 ; I <= N ; I+= 1) { printf ("\n Ingrese UN NUMERO : "); scanf ("%d",&NUM); if (NUM != 0) if (pow(-1,NUM) > 0) CUEPAR = CUEPAR + 1; else CUEIMP = CUEIMP + 1; } printf ("\n\n La cantidad de PARES es : %10.2d ",CUEPAR); printf ("\n\n La cantidad de IMARES es : %10.2d ",CUEIMP); return 0; }

Universidad Mariano Glvez de Retalhuleu Facultad de Ingeniera en Sistemas Ing. Alexis A. Jurez /*UMG-REU, CURSO DE ALGORITMOS */ /* El PROGRAMA escribe y suma los trminos de una serie */ /*********************************************************/ #include<stdio.h> main() { char BAND; int I , N ; float SERIE ; SERIE = 0; BAND = 'T'; printf ("\n Ingres el nmero de trminos "); scanf (" %d",&N); for ( I = 1 ; I <= N ; I+= 1) { if (BAND == 'T') { SERIE = SERIE + (1.0 / I); BAND = 'F'; } else { SERIE = SERIE - (1.0 / I); BAND = 'T'; } } printf ("\n\n La Suma de la SERIE es : %10.4f",SERIE); return 0; }

Universidad Mariano Glvez de Retalhuleu Facultad de Ingeniera en Sistemas Ing. Alexis A. Jurez //UMG-REU, CURSO DE ALGORITMOS /*El PROGRAMA, dadas las caractrsticas fsicas de la */ /* poblacin de un departamento de Guatemala, obtiene los*/ /* promedios de PESO y ALTURA de dicha poblacin. */ /*********************************************************/ #include<stdio.h> main() { int I , N , SEX ; float PES , ALT , PESO , ALTU , PROMPE , PROMAL ; PESO = 0; ALTU = 0; printf ("\n Ingrese EL Nmero de PERSONAS : "); scanf (" %d",&N); for ( I = 1 ; I <= N ; I+=1) { printf ("\n Ingrese EL PESO : "); scanf (" %f",&PES); printf ("\n Ingrese La Altura : "); scanf (" %f",&ALT); printf ("\n Ingrese EL SEXO : "); scanf (" %d",&SEX); PESO = PESO + PES; ALTU = ALTU + ALT; } PROMPE = PESO / N; PROMAL = ALTU / N; printf ("\n El Promedio del Peso es : %10.2f ",PROMPE); printf ("\n El Promedio de la Altura es : %10.2f ",PROMAL); return 0; }

Universidad Mariano Glvez de Retalhuleu Facultad de Ingeniera en Sistemas Ing. Alexis A. Jurez //UMG-REU,CURSO DE ALGORITMOS /* El PROGRAMA, dado un entero positivo, obtiene y escribe*/ /* la sucesin de ULAM. */ /*********************************************************/ #include<stdio.h> #include<math.h> main() { int N ; printf ("\n Ingrese El Nmero : "); scanf (" %d",&N); if ( N > 0) { printf ("\n El valor de N es : %d ",N); while ( N != 1) { if ( pow(-1,N) > 0 ) N = N / 2; else N = (N * 3) + 1; printf ("\n El valor de N es : %d ",N); } } else printf ("\n\n N tiene que ser un entero posisitvo"); return 0; }

Universidad Mariano Glvez de Retalhuleu Facultad de Ingeniera en Sistemas Ing. Alexis A. Jurez //UMG-REU, CURSO DE ALGORITMOS /*********************************************************/ #include<stdio.h> main() { int I , SUM ; SUM = 0.0; for ( I = 10 ; I <= 50 ; I+=2) SUM = SUM + I; printf ("\n La SUMA DE LOS PARES es : %d ",SUM);

return 0; }

Universidad Mariano Glvez de Retalhuleu Facultad de Ingeniera en Sistemas Ing. Alexis A. Jurez

//UMG-REU, CURSO DE ALGORITMOS /* El PROGRAMA, calcula el capital que se tendr en el */ /* banco, luego de haber depositado un cierto capital, */ /* durante cierto tiempo, a una tasa de inters variable.*/ /*********************************************************/ #include<stdio.h> main() { int I , MESES ; float CAPINI , TASA , CAPFIN ; printf ("\n Ingrese El Capital inicial : "); scanf (" %f",&CAPINI); printf ("\n Ingrese Los Meses : "); scanf (" %d",&MESES); for ( I = 1 ; I<= MESES ; I+=1) { printf ("\n Ingrese La TASA : "); scanf (" %f",&TASA); CAPFIN = CAPINI + (CAPINI * TASA / 100); CAPINI = CAPFIN; } printf ("\n\n El Capital Final ser : %10.2f ",CAPFIN); return 0; }

Universidad Mariano Glvez de Retalhuleu Facultad de Ingeniera en Sistemas Ing. Alexis A. Jurez //UMG-REU, ALGORITMOS //Ing. Alexis A. Jurez //programa que muestra el uso del do while //imprimiendo los nmeros del 1 al 10 //esta es una estructura condicional, que permite realizar por lo menos una vez todo el //proceso que se encuentra dentro de si. Al final verifica si la condicin se cumple o no //y contina su ejecucin siempre y cuando la condicin sea falsa. #include<stdio.h> main(void) { int dato=1; printf("I T E R A C I O N D E L P R O G R A M A \n\n"); do { printf(" %d \n ",dato); dato = dato + 1; } while(dato<=10); return 0; }

Universidad Mariano Glvez de Retalhuleu Facultad de Ingeniera en Sistemas Ing. Alexis A. Jurez //UMG-REU, CURSO DE ALGORITMOS //ING.ALEXIS JUAREZ //Programa que opera aritmticamente dos nmeros enteros por mdio de men #include<iostream.h> #include<stdio.h> #include<conio.h> //Prototipo de las funciones int sumar(int,int); int restar(int,int); int multiplicar(int,int); int dividir(int,int); void main (void) {int a,b,c,opcion; //****************************************************** do{//inicio del do

clrscr(); cout<<endl<<"UNIVERSIDAD MARIANO GALVEZ DE RETALHULEU - CURSO DE ALGORITMOS"; cout<<endl<<" CREADO POR EL ING. ALEXIS A. JUAREZ \n"; cout<<endl<<"EL SIGUIENTE PROGRAMA LE PERMITE OPERAR ARITMETICAMENTE DOS NUMEROS"<<endl; cout<<"SE LE PEDIRA QUE INGRESE DOS DIGITOS Y A CONTINUACION USTED DEBERA DE"<<endl; cout<<"INDICAR QUE OPERACIN DESEA EJECUTAR"<<endl<<endl; cout<<" Press Any Key to continue..."; getch(); cout<<endl<<endl<<"INGRESE EL PRIMER DIGITO Y PRESIONE ENTER: "; cin>>a; cout<<"INGRESE EL SEGUNDO DIGITO Y PRESIONE ENTER: "; cin>>b; clrscr(); cout<<"CON EL NUMERO DE OPCION QUE CORRESPODE INDIQUE QUE DESEA HACER CON EL "<<a<<" Y EL "<<b; printf(" LUEGO PRESIONE ENTER\n\n\n"); printf(" OPCION \n"); printf(" 1---->S U M A R L O S \n\n"); printf(" 2---->R E S T A R L O S \n\n"); printf(" 3---->M U L T I P L I C A R L O S\n\n");

Universidad Mariano Glvez de Retalhuleu Facultad de Ingeniera en Sistemas Ing. Alexis A. Jurez printf(" 4---->D I V I D I R L O S\n\n"); printf(" 5---->S A L I R D E L P R O G R A M A \n\n"); cout<<"OPCION: "; cin>>opcion;

10

if(opcion==1) //LLAMADA A LA FUNCION SUMA SI SE PRESIONA LA OPCION 1 { c=sumar(a,b);//llamada cout<<endl<<"EL RESULTADO ES: "<<a<<" + "<<b<<" = "<<c<<endl<<endl<<"Press Any Key to Continue..."; getch();//pausa en pantalla, presione cualquier tecla } if(opcion==2) //LLAMADA A LA FUNCION RESTA SI SE PRESIONA LA OPCION 2 { c=restar(a,b);//primera llamada cout<<endl<<"EL RESULTADO ES: "<<a<<" - "<<b<<" = "<<c<<endl<<endl<<"Press Any Key to continue..."; getch();//pausa en pantalla } if(opcion==3)//LLAMADA A LA FUNCION MULTIPLICACION SI SE PRESIONA LA OPCION 3 { c=multiplicar(a,b);//primera llamada cout<<endl<<"EL RESULTADO ES: "<<a<<" * "<<b<<" = "<<c<<endl<<endl<<"Press Any Key to continue..."; getch(); } if(opcion==4)//LLAMADA A LA FUNCION DIVIDIR SI SE PRESIONA LA OPCION 4 { c=dividir(a,b); cout<<endl<<"EL RESULTADO ES: "<<a<<" / "<<b<<" = "<<c<<endl<<endl<<"Press Any Key to continue...";

Universidad Mariano Glvez de Retalhuleu Facultad de Ingeniera en Sistemas Ing. Alexis A. Jurez getch(); } }//fin del do while(opcion>=1&&opcion<=4); cout<<endl<<endl<<"A D I O S..."; } int sumar(int x,int y)//FUNCION SUMA { int result; result=x+y; return result; } int restar(int x,int y)//FUNCION RESTA { int result; result=x-y; return result; } int multiplicar(int x,int y)//FUNCION MULTIPLICACION { int result; result=x*y; return result; } int dividir(int x,int y)//FUNCION DIVISION { int result; result=x/y; return result; }

11

Vous aimerez peut-être aussi