Sei sulla pagina 1di 21

Taller

Ciclos (For/While)
Jess David Galindo Juan Camilo vila

1. For
PSEINT:
Proceso promedio
para x=1 hasta 7 Con Paso 1 Hacer
leer calf;
Sum= sum + calf;
FinPara
prom= sum/7
Escribir prom;
FinProceso

COUT:
#include <iostream>
#include <cstdlib>
#include <stdlib.h>
using namespace std;
int main()
{
system ("color f5");
int calif,x;
float prom,suma;
for (x=1; x<=7; x++)
{
cout <<"Digite la calificacion: ";
cin >> calif;
suma = suma + calif;
}
prom = (suma/7);
cout << "\n El promedio de las calificaciones es: " << prom;
return 0;
}

PRINTF:
#include <iostream>
#include <cstdlib>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
int main()
{
system ("color f5");
int calif,x;
float prom,suma;
for (x=1; x<=7; x++)
{
printf ("Digite la calificacion: ");
scanf ("%d",&calif);

suma = suma + calif;


}
prom = (suma/7);
printf("\n El promedio de las calificaciones es: %f",prom);
return 0;
}

While
PSEINT:
Proceso promedio
suma=0
x=1
mientras x<=7 Hacer
escribir "digite la calificacion:";
Leer calf;
Sum= sum + calf;
x=x+1
Finmientras
prom= sum/7
Escribir "el promedio de calificaciones es:",prom;
FinProceso

COUT:
#include <iostream>
#include <cstdlib>
#include <stdlib.h>
using namespace std;
int main()
{
system ("color f5");
int calif=0,num=0;
float prom,suma;
while (num<7)
{
cout <<"Digite la calificacion: ";
cin >> calif;
suma = suma + calif;
num++;
}
prom = (suma/7);
cout << "\n El promedio de las calificaciones es: " << prom;
return 0;
}

PRINTF:

#include
#include
#include
#include

<iostream>
<cstdlib>
<stdlib.h>
<stdio.h>

using namespace std;


int main()
{
system ("color f5");
int calif=0,num=0;
float prom,suma;
while (num<7)
{
printf ("Digite la calificacion: ");
scanf ("%d", &calif);
suma = suma + calif;
num++;
}
prom = (suma/7);
printf ("\n El promedio de las calificaciones es: %f ",prom);
return 0;
}

2. For
PSEINT:
Proceso cubo
Para x=1 hasta 10 Con Paso 1 Hacer
Leer num;
c= (num)^3;
cu= c*num
Escribir "cubo:",c;
Escribir "cuarta:",cu;
FinPara
FinProceso

COUT:
#include<iostream>
#include<stdlib.h>
using namespace std;
int main(int argc, char *argv[]) {
system ("color f5");
int num, x;
for(x=0; x < 10; x++)
{
cout<<"\nIngrese un numero: "<<ends;
cin>> num;
cout <<"El cubo es: "<<num*num*num<<endl;

cout <<"La cuarta es:"<<num*num*num*num<<endl;


}
return 0;
}
PRINTF:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
using namespace std;
int main(int argc, char *argv[]) {
system ("color f5");
int num, x;
for(x=0; x < 10; x++){
printf("\nIngrese un numero: ");
scanf("%d", &num);
printf("El cubo es: %d \n",num*num*num);
printf("La cuarta es: %d \n",num*num*num*num);
}
getche();
}

While
PSEINT:
Proceso cubo
x=0
mientras x<=10 Hacer
Leer num;
c= (num)^3;
cu= c*num
Escribir "cubo:",c;
Escribir "cuarta:",c;
Finmientras
FinProceso

COUT:
#include<iostream>
#include<stdlib.h>
using namespace std;
int main(int argc, char *argv[]) {
system ("color f5");
int num=0, x=1;
while (x <=10)
{
cout<<"\nIngrese un numero: "<<ends;
cin>> num;
x++;
cout <<"El cubo es: "<<num*num*num<<endl;

cout <<"La cuarta es: "<<num*num*num*num<<endl;


}

PRINTF:
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int main(int argc, char *argv[]) {
system ("color f5");
int num=0, x=1;
while (x <=10)
{
printf ("\nIngrese un numero:");
scanf ("%d", &num);
x++;
printf (" El cubo es: %d \n",num*num*num );
printf (" La cuarta es: %d \n",num*num*num*num);
}
return 0;
}

3. For
PSEINT
Proceso positivos
para x=1 hasta 10 con paso 1 hacer
leer num;
Si num>0 Entonces
Imprimir num
FinSi
FinPara
FinProceso
COUT
#include <iostream>
#include<stdlib.h>
using namespace std;
int main(int argc, char *argv[]) {
system("color f5");
int num,x;
for(x=1;x<10;x++){
cout<<"\n Ingrese un numero: ";
cin>>num;
if(num>0){
cout<<num<<" ";
}

}
return 0;
}
PRINTF
#include <iostream>
#include <stdio.h>
#include<stdlib.h>
using namespace std;
int main(int argc, char *argv[]) {
system("color f5");
int num,x;
printf("Ingrese el numero");
for(x=0; x<10; x++){
printf("\n%d.", x+1);
scanf("%d", &num);
if (num>0)
printf("\n%d",num);
}
return 0;
}

While
PSEINT:
Proceso promedio
num=0
x=1
mientras x<=10 Hacer
escribir "digite el numero:";
Leer num;
Si num>0 Entonces
Imprimir num
x=x+1
FinSi
Finmientras
FinProceso
COUT
#include <iostream>
#include<stdlib.h>
using namespace std;
int main(int argc, char *argv[]) {
system("color f5");
int x=0,num=0;

while(x<10)
{
cout<<"\n Ingrese un numero: ";
cin>>num;
if(num>0)
cout<<num<<" ";
x++;
}
return 0;
}
PRINTF
#include <iostream>
#include <stdio.h>
#include<stdlib.h>
using namespace std;
int main(int argc, char *argv[]) {
system("color f5");
int x=0,num=0;
printf("Ingrese el numero");
while(x<10){
printf("\n%d.", x+1);
scanf("%d", &num);
if (num>0)
printf("\n%d",num);
x++;
}
return 0;
}

4. For
PSEINT:
Proceso NUMEROS
para x=1 hasta 6 con paso 1 hacer
Escribir "Digite el nmero";
leer num;
si num = 0 entonces
cn= n+1
Sino
si num>0 Entonces
cp= cp+1
Sino
cneg= cneg +1
FinSi
FinSi
FinPara
escribir "cantidad numeros positivos",cp;

escribir "cantidad numeros negativos",cneg;


escribir "cantidad numeros neutros",cn;
FinProceso

COUT:
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(int argc, char *argv[]) {
system ("color f5");
int positivo=0, negativo=0, neutro=0, n, x;
for(x=1; x<=6; x++){
cout<<"Ingrese un numero: "<<ends;
cin>>n;
if( n > 0 )
{
positivo++;
}
if( n < 0 )
{
negativo++;
}
if( n == 0 )
{
neutro++;
}
}
cout<<"\nCantidad de positivos: "<<positivo<<endl;
cout<<"\nCantidad de negativos: "<<negativo<<endl;
cout<<"\nCantidad de neutros: "<<neutro<<endl;
return 0;
}

PRINTF:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main(int argc, char *argv[]) {
system ("color f5");
int positivo=0, negativo=0, neutro=0, n, x;
for(x=1; x<=6; x++){
printf("Ingrese un numero: ", x);
scanf("%d", &n);
if( n > 0 )
{
positivo++;
}

if( n < 0 )
{
negativo++;
}
if( n == 0 )
{
neutro++;
}

}
printf("\nCantidad de positivos: %d", positivo);
printf("\nCantidad de negativos: %d", negativo);
printf("\nCantidad de neutros: %d\n", neutro);
}

return 0;

While
PSEINT:
Proceso NUMERS
cn=0
cp=0
cneg=0
mientras x<=6 hacer
Escribir "Digite el nmero:";
leer x;
si x = 0 entonces
cn= cn+1
Sino
si x>0 Entonces
cp= cp+1
Sino
cneg= cneg +1
FinSi
FinSi
Finmientras
escribir "cantidad numeros positivos:",cp;
escribir "cantidad numeros negativos:",cneg;
escribir "cantidad numeros neutros:",cn;
FinProceso
COUT:
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(int argc, char *argv[]) {
system ("color f5");
int positivo=0, negativo=0, neutro=0, x=1;
while (x<=6){
cout<<"Ingrese un numero: "<<ends;
cin>>x;

if( x > 0 )
{
positivo++;
}
if( x < 0 )
{
negativo++;
}
if (x=0)
{
neutro++;
}

}
cout<<"\nCantidad de positivos: "<<positivo<<endl;
cout<<"\nCantidad de negativos: "<<negativo<<endl;
cout<<"\nCantidad de neutros: "<<neutro<<endl;
}
PRINTF:

return 0;

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main(int argc, char *argv[]) {
system ("color f5");
int positivo=0, negativo=0, neutro=0, x=1;
while(x<=6)
{
printf("Ingrese un numero: ");
scanf("%d", &x);
if( x > 0 )
{
positivo++;
}
if( x < 0 )
{
negativo++;
}
if( x =0 )
{
neutro++;
}
}
printf("\nCantidad de positivos: %d", positivo);
printf("\nCantidad de negativos: %d", negativo);
printf("\nCantidad de neutros: %d\n", neutro);
}

return 0;

5. For
PSEINT:
Proceso positivos
para x=1 hasta 5 con paso 1 Hacer
leer num;
p= num*(-1);
Escribir "positivo:",p;
FinPara
FinProceso
COUT:
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(int argc, char *argv[]) {
system ("color f5");
int num,x,positivo;
for (x=0;x<5;x++)
{
cout<<"\nDigite el numero negativo: "<<ends;
cin>>num;
positivo=num*-1;
cout<<"Numero positivo: "<<positivo<<endl;
}
}

return 0;

PRINTF:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main(int argc, char *argv[]) {
system ("color f5");
int num,x,positivo;
for (x=0;x<5;x++)
{
printf("\nDigite el numero negativo: ");
scanf("%d", &num);
positivo=num*-1;
printf ("Numero positivo: %d \n",positivo);
}
}

return 0;

While
PSEINT:
Proceso positivos
x=1
Mientras x<=15 Hacer
leer num;
p= num*(-1);
Escribir "positivo:",p;
FinMientras
FinProceso
COUT:
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(int argc, char *argv[]) {
system ("color f5");
int num,x=1,positivo;
while (x<=15)
{
cout<<"\nDigite el numero negativo: "<<ends;
cin>>num;
positivo=num*-1;
cout<<"Numero positivo: "<<positivo<<endl;
}
return 0;
}

PRINTF:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main(int argc, char *argv[]) {
system ("color f5");
int num,x=1,positivo;
while (x<=15)
{
printf("\nDigite el numero negativo: ");
scanf("%d", &num);
positivo=num*-1;
printf ("Numero positivo: %d \n",positivo);

}
return 0;
}

6. For
PSEINT
Proceso nota
suma=0
baja=9999
escribir ingrese sus notas;
para x=1 hasta 5 con paso 1 hacer
leer calif;
sum= sum + calif
si calif < baja entonces
baja=calif
FinSi
FinPara
media= sum/2
Escribir el numero medio es:,media;
Escribir la nota mas baja es:,baja;
FinProceso
COUT
#include <iostream>
#include <stdlib.h>
#include <conio.h>
using namespace std;
int main(int argc, char *argv[]) {
system (color f5);
int notas[5],n,S,menor,Prom;
for(n=0; n<5; n++)
{
notas[n] = 0;
}
cout << Ingrese las notas de los alumnos: \n\n;
for(n=0; n<5; n++)
{
cout << Alumno << n+1 << : ;
cin >> notas[n];
}
S=0;

for(n=0; n<5; n++)


{
S+=notas[n];
}
Prom = S/5;
menor = 1000;
for(n=0; n<5; n++)
{
if(menor>notas[n])
{
menor = notas[n];
}
}
cout << \nLa media de las notas es: << Prom << . Y la nota ms
baja es: << menor;
return 0;
}
PRINTF
#include <iostream>
#include <stdlib.h>
#include <conio.h>
#include <stdio.h>
using namespace std;
int main(int argc, char *argv[]) {
system (color f5);
int notas[5],n,S,menor,Prom;
for(n=0; n<5; n++)
{
notas[n] = 0;
}
printf(Ingrese las notas de los alumnos: );
for(n=0; n<5; n++)
{
printf ( Alumno:%d,n+1);
scanf (%d, &notas[n]);
}
S=0;
for(n=0; n<5; n++)
{
S+=notas[n];
}
Prom = S/5;

menor = 1000;
for(n=0; n<5; n++)
{
if(menor>notas[n])
{
menor = notas[n];
}
}
printf (\nLa media de las notas es:%d ,Prom , \n Y la nota ms baja es:
%d ,menor);
return 0;
}

While
PSEINT
Proceso nota
suma=0
baja=9999
x=1
mientras x<=5 hacer
escribir "digite la calificacion";
leer calif;
sum= sum + calif
x=x+1
FinMientras
si calif < baja entonces
baja=calif
FinSi
media= sum/2
Escribir " el numero medio es:",media;
Escribir " la nota mas baja es:",baja;
FinProceso
COUT
#include <iostream>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
using namespace std;
int main(int argc, char *argv[]) {
system("color f5");

float x,s,baja,c,m;
s=0;
baja= 9999;
x=1;
while (x<=40)
{
cout<<"digite calificacin:"<<endl;
cin>>c;
x=x+1;
s=s+c;
if(c<baja)
{
baja=c;
}
}
m=s/2;
cout<<"la media es:"<<m<<ends;
cout<<"la nota mas baja es:"<<baja<<ends;
getch();
getch ();

PRINT F
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main(int argc, char *argv[]) {
system("color f5");
float x,s,baja,c,m;
s=0;
baja= 9999;
x=1;
while (x<=40)
{
printf ("\n digite calificacion:");
scanf ("%f",&c);
x=x+1;
s=s+c;

if(c<baja)
{
baja=c;
}
}
m=s/2;
printf ("\n la media es:%f",m);
printf ("\n la nota ms baja es:%f",baja);
getch();
}

7. For
PSEINT
Proceso multiplicar
Leer num;
para x=1 hasta 20 con paso 1 Hacer
resul= num*x
Escribir num,"*",x,"=",resul
FinPara
FinProceso
COUT
#include <iostream>
#include <stdlib.h>
using namespace std;
int main() {
system ("color f5");
int numero;
cout<<"Ingrese un numero: ";
cin>>numero;
cout<<"\nTabla del "<<numero;
cout<<endl;
for(int x = 1; x < 11; x++)
{
cout<<x<<"*"<<numero<<"="<<x*numero;
cout<<endl;
}
return 0;
}
PRINTF
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include<conio.h>
using namespace std;

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


system ("color f5");
int X, num, resul=0;
printf("Ingrese el nro a multiplicar");
scanf("%d", &num);
for( X=0; X<=10; X++) {
resul = num * X;
printf("\n%d X %d =%d", num,X, resul);
}
getche();
}

While
PSEINT
Proceso promedio
num=0
x=1
mientras x<=10 Hacer
escribir "digite el numero:";
Leer num;
Si num>0 Entonces
Imprimir num
x=x+1
FinSi
Finmientras
FinProceso
COUT
#include <iostream>
#include <stdlib.h>
using namespace std;
int main() {
system ("color f5");
int numero=0,x=0;
cout<<"Ingrese un numero: ";
cin>>numero;
cout<<"\nTabla del "<<numero;
cout<<endl;
while(x<11)
{
cout<<x<<"*"<<numero<<"="<<x*numero;
cout<<endl;
x++;
}
return 0;
}

PRINTF
#include <iostream>
#include <stdio.h>
#include<stdlib.h>
using namespace std;
int main() {
system ("color f5");
int numero=0,x=0;
printf("Ingrese un numero: ");
scanf("%d", &numero);
printf("\nTabla del ",numero);
while(x<11)
{
printf("\n%d X %d =%d", numero,x,numero*x);
x++;
}
return 0;
}

8. For
PSEINT
Proceso reloj
para h=1 hasta 23 Hacer
para m=1 hasta 59 Hacer
para s=1 hasta 59 Hacer
Escribir h,":",m,":",s;
FinPara
FinPara
FinPara
FinProceso

COUT
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main(int argc, char *argv[]) {
int h,m,s;
for( h=1; h<=23; h++)
{
for( m=1; m<=59; m++)
{
for( s=1; s<=59; s++)
{
cout<<h<<"horas"<<m<<"min"<<s<<"seg."<<endl;
}

}
}
return 0;
}

PRINTF
#include <stdio.h>
using namespace std;
int main(int argc, char *argv[]) {
int h,m,s;
for( h=1; h<=23; h++)
{
for( m=1; m<=59; m++)
{
for( s=1; s<=59; s++)
{
printf("\n %d horas %d min %d seg.", h,m,s);
}
}
}
return 0;
}

Potrebbero piacerti anche