PROGRAMACIÓN ESTRUCTURADA
NOMBRE: ELIAS CORNEJO
NIVEL:Segundo “B”
FECHA:29 de Abril del 2013.
DESARROLLAR LA CODIFICACION EN C++, SUBIR LOS *CPP Y AL *EXE AL BLOG, TRAER IMPRESO ENTRE DOS NÚMEROS INGRESADOS POR EL TECLADO.
HACER UN PROGRAMA QUE PERMITA CALCULAR TODOS LOS NÚMEROS PRIMOS ENTRE DOS NÚMEROS INGRESADO POR EL TECLADO.
#include <iostream.h>
#include <conio.h>
int main()
{
int fila,np,np2,d,col,j,cont;
col=2,j=0;cont=0;
fila=8;
clrscr();
gotoxy(15,3);cout<<"NUMEROS PRIMOS, DE DOS NUMEROS INGRESADOS POR TECLADO";
gotoxy(20,5);cout<<"Ingrese el primer numero";
gotoxy(48,5);cin>>np;
gotoxy(20,6);cout<<"Ingrese el segundo numero";
gotoxy(48,6);cin>>np2;
if (np>np2)
{
gotoxy(20,7);cout<<"El primer numero debe de ser menor...";
}
if ((np<=0) || (np2<=0))
{
gotoxy(20,7);cout<<"Los numeros deben de ser mayores a 0...";
}
else
{
for (int j=np;j<=np2;j++)
{
d=np;
for (int i=1; i<=np;i++)
{
if (np % d == 0)
{
cont++;
}
d--;
}
if (cont ==2)
{
gotoxy(col,fila);cout<<np;
col=col+5;
if (col>75)
{
col=2;
fila++;
}
}
np++;
cont=0;
}
}
getch();
return 0;
}
ESCRIBIR UN PROGRAMA QUE IMPRIMA LOS NUMEROS DEL 1 AL 10, CADA UNO DE ELLOS CON SU RESPECTIVA FACTORIAL.
#include <iostream.h>
#include <conio.h>
int main()
{
int fila;
float fact;
fila=7;
clrscr();
gotoxy(20,3);cout<<"FACTORIAL DE LOS 10 PRIMEROS NUMEROS";
gotoxy(25,5);cout<<"NUMERO FACTORIAL";
for (int n=1; n<=10; n++)
{
fact=1;
for(int i=n;i;i--)
{
fact=fact*i;
gotoxy(27,fila);cout<<n<<" = "<<fact;
}
fila++;
}
getch();
return 0;
}
ESCRIBIR UN PROGRAMA QUE PERMITA PASAR UN NUMERO NATURAL CUALQUIERA A BINARIO.
#include <iostream.h>
#include <conio.h>
int main()
{
int col,nat,bina;
col=39;
clrscr();
gotoxy(15,3);cout<<"CONVERTIR UN NUMERO NATURAL A BINARIO";
gotoxy(15,4);cout<<"El numero a convertir es ==> ";
gotoxy(47,4);cin>> nat;
if (nat>=2)
{
for (int i=1; i>0; i++)
{
bina=nat%2;
gotoxy(col,6);cout<<bina;
nat=nat/2;
col=col-1;
if (nat==1)
break;/* permite salir de un FOR y continuar afuera del mismo*/
}
gotoxy(col,6);cout<<"1";
gotoxy(col+9,6);
}
getch();
return 0;
}
CALCULAR EL ACUMULADO DE LAS EDADES DE UN GRUPO DE N PERSONAS SIEMPRE Y CUANDO DICHAS EDADES SEAN MAYORES A 18 Y NO PASEN DE 45.
#include <iostream.h>
#include <conio.h>
int main()
{
int n,edad, acueda,col;
col=10; acueda=0;
clrscr();
gotoxy(20,3);cout<<"PROGRAMA QUE PERMITE INGRESAR N EDADES";
gotoxy(20,4);cout<<"ENTRE 18 A 45 A;OS";
gotoxy(10,7);cout<<"Ingresa el numero de personas";
gotoxy(42,7);cin>>n;
gotoxy(10,8);cout<<"Ingresa EDAD y presiona enter";
for (int i=0; i<n; i++)
{
gotoxy(col,10);cin>>edad;
if ((edad>=18) & (edad<=45))
{
acueda=acueda+edad;
}
col=col+5;
}
gotoxy(10,12);cout<<"El ACUMULADO de las EDADES es " << acueda ;
getch();
return 0;
}
HACER EN PROGRAMA QUE MUESTRE LOS NÚMEROS PARES ENTRE 1000 Y 0. NO SE ESCRIBIRÁ LOS NÚMEROS QUE SE ENCUENTREN EN EL RANGO DE 200 A 50.
#include <iostream.h>
#include <conio.h>
int main()
{
int n,col,fil;
col=1;fil=3;
clrscr();
gotoxy(12,1);cout<<"PROGRAMA QUE PERMITE MOSTRAR EN PANTALLA LOS NUMEROS PARES";
gotoxy(9,2);cout<<"ENTRE 1000 A 0, NO SE ESCRIBIRA LOS COMPRENDIDOS ENTRE 50 Y 200";
for (int i=0; i<=1000; i++)
{
if ((i>=50) & (i<=200))
{
continue;
}
else
{
if (i % 2 == 0)
{
gotoxy(col,fil);cout<< i;
}
}
if (col>=75)
{
fil++;
col=1;
}
else
col=col+2;
}
getch();
return 0;
}
DADOS LOS NÚMEROS HACER UN PROGRAMA QUE DETERMINE LA SUMA DE LOS QUE SEAN MAYORES A CERO, EL PRODUCTO DE LOS MENORES QUE CERO Y SE CUENTEN CUANTOS NÚMEROS SON IGUALES A CERO.
#include <iostream.h>
#include <conio.h>
int main()
{
int n,col,num,suma,prod,cont;
col=1;suma=0;prod=1;cont=0;
clrscr();
gotoxy(12,1);cout<<"PROGRAMA QUE PERMITE INGRESAR N NUMEROS Y DETERMINAR LA SUMA";
gotoxy(9,2);cout<<"DE LOS QUE SEAN > A 0, EL PRODUCTO DE LOS < A 0 Y CONTAR = A 0 ";
gotoxy(9,3);cout<<"Ingresar el numero de veces que se repetira el bucle";
gotoxy(62,3); cin>> n;
gotoxy(9,4);cout<<"Ingrese el valor y presione enter...";
for (int i=1; i<=n; i++)
{
gotoxy(col,6);cin>> num;
if (num>0)
{
suma=suma+num;
}
else
{
if (num < 0)
{
prod=prod*num;
}
}
if (num==0)
{
cont++;
}
col=col+5;
}
gotoxy(15,10);cout<<"La suma de los mayores a 0 es ==> "<< suma;
gotoxy(15,11);cout<<"El producto de los menores a 0 es ==> " <<prod;
gotoxy(15,12);cout<<"La cantidad de numeros iguales a 0 son ==> " <<cont;
getch();
return 0;
}
HACER UN PROGRAMA PARA CALCULAR LA SUMA DE LOS 15 PRIMEROS NÚMEROS DE LA SERIE FIBONACCI.
#include <iostream.h>
#include <conio.h>
int main()
{
int col,a,b,suma;
double fibo;
col=8;a=0;b=1;fibo=0;
clrscr();
gotoxy(3,1);cout<<"PROGRAMA QUE MUESTRE LA SUMA DE LOS 15 PRIMEROS NUMEROS DE LA SERIE FIBONACCI";
gotoxy(1,3);cout<<"0 1 ";
for (int i=1; i<=13; i++)
{
fibo=a+b;
gotoxy(col,3);cout<<fibo;
suma=suma+fibo;
a=b;
b=fibo;
col=col+4;
}
gotoxy(15,10);cout<<"La suma de los 15 primeros numeros es ==> "<< suma+1;
getch();
return 0;
}