miércoles, 27 de mayo de 2009

Ciclos Repetitivos - Para

1. Hacer un algoritmo que cuente los numeros positivos y que cuente los numeros negativos q hay entre 321 y 484.

programando:

#include
#include

using namespace std;

int main(int argc, char *argv[])
{
cout<<"cuantos positivos hay entre el rango de 321 y 484"<
int i,w;

w=0;

for (i=322;i<484;i=i+1) w="w+1;"> cout<<"hay: "<


system("PAUSE");
return EXIT_SUCCESS;
}

2. Realizar un algortimo que lea 10 numeros ingresados por teclado y determine cuantos son positivo,negativo o iguales a cero:

programado:

#include
#include

using namespace std;

int main(int argc, char *argv[])
{
cout<<"progrma q lee 10 # ingresados x tclado y dtrmina cuantos son positivos,"< cout<<" ngativos o iguals a cro"< cout<
int k,w,d,f,e;

e=0;
f=0;
d=0;

for (w=1;w<=10;w=w+1)
{
cout<<"ingrec k x favor: "< cin>>k;

if(k==0)
{
e=e+1;
}
else
if(k<0)
{
f=f+1;
}
else
d=d+1;
}
cout<<"hay: "< cout<<"hay: "< cout<<"hay: "<


system("PAUSE");
return EXIT_SUCCESS;
}

No hay comentarios:

Publicar un comentario