Está en la página 1de 4

ESTRUCTURAS REPETITIVAS

1) cout <<" \tAlgoritmo Suma de 10 Nros\n"<<endl;

void main(int argc, char* argv[ ])


int num,s,c;
cout<<"SUMA DE 10 Nrs\n"<<endl;
c=1;
s=0;
while (c<=10)
{ cout<<"\tIngrese el numero: ";
cin>>num;
s=s+num;
c=c+1;
}
cout<<"la suma es: "<<s<<endl;
getch();

2) cout<<" \tAlgoritmo Suma de N Nros\n"<<endl;

void main(int argc, char* argv[ ])


{
int N,nro,sum,c;
cout<<"Ingresar cantidad de nmeros: ";
cin>>N;
c=0;
sum=0;
while (c<N)
{ cout<<"Ingresar el numero: ";
cin>>nro;

sum=sum+nro;
c=c+1;
}
cout<<"La suma es: "<<sum<<endl;
getch();

3) cout<<" \tAlgoritmo Promedio de 10\n"<<endl;

void main(int argc, char* argv[ ])


{
double nota,sum,c;
int prom;
c=1;
sum=0;
while (c<=10)
{ cout<<"ingresar la nota: ";
cin>>nota;
sum=sum+nota;
c=c+1;
}
prom=sum/10;
cout<<"el promedio es: "<<prom<<endl;
getch();
}
4) cout <<" \tAlgoritmo Promedio de N\n"<<endl;

int main(int argc, char* argv[ ])


{
double nota,s,N,c;
int P;
cout<<"Ingrese cantidad de nmeros: ";
cin>>N;
c=0;
s=0;

while (c<N)
{ cout<<"Ingrese las notas: ";
cin>>nota;
s=s+nota;
c=c+1;
}
P=s/N;
cout<<"El promedio de las notas es: "<<P;
getch();

5) cout <<" \tMayor Nro de N \n"<<endl;

void main(int argc, char* argv[])


{
int N,num,c,may;
cout<<"ingrese la cantidad de numeros: ";
cin>>N;
c=0;
may=0;
while (c<N)
{ cout<<"ingrese los numeros: ";
cin>>num;
if (num>may)
{ may=num;
}
c++;
}
cout<<"el n mayor es: "<<may;
getch();

6) int N,num,c,men;
cout<<"Ingrese la cantidad de numeros: ";
cin>>N;
c=0;
men=0;

while (c<N)
{ cout<<"Ingrese los numeros: ";
cin>>num;
if (num<men)
{ men=num;
}
c++;
}
cout<<"El Nro Menor es: "<<men;
getch();
7) int num,S,N,c;
cout<<"Ingrese la Cantidad n Nros :";
cin>>num;
c=0;
S=0;
while (num>0)
{ cout<<"Ingrese el Nro :";
cin>>num;
if (num>50)
{ S=S+num;
}
c=c+1;
}
cout<<"La Suma de Mayores es :"<<S;
getch();

8) int num,S,N,c;
cout<<"Ingrese la cantidad de Nros :";
cin>>N;
c=0;
S=0;
do
{ cout<<"Ingrese e Nro :";
cin>>num;
if (num>50)
{ S+=num;
}
c=c+1;
}while (c<N);
cout<<"La suma de los mayores es: "<<S;
getch();
9) double N,pos,neg,cero,num,c,xpos,xneg,xcero;
pos=0;
neg=0;
cero=0;
c=0;
cout<<"Ingrese la Cantidad de Nros :";
cin>>N;
while(c<N)
{ cout<<"Ingrese el Nro: ";
cin>>num;
xcero=xcero+cero;
if (num>0)
{ pos=1;
xpos=xpos+pos;
}
else if (num<0)
{ neg=1;
xneg=xneg+neg;
}
else
{ cero=1;
xcero+=cero;
}
c=c+1;
}
cout<<"\tLas Cantidade de Negativos es: "<<xneg;
cout<<"\tLas Cantidade de Positivos es: "<<xpos;
cout<<"\tLas Cantidade de Ceros es: "<<xcero;
getch();

También podría gustarte