Files
Borland-C/CPP/PROG2.CPP

90 lines
1.8 KiB
C++
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Prog2
// Programadores:
// Juan L¢pez Fern ndez
// Moiss Virumbrales Cuenca
// DAI 1§A
// Imprimir, contar y sumar los elementos m£ltiplos de 7 comprendidos
// entre 1 y un n£mero introducido por teclado previamente.
#include <stdio.h>
#include <conio.h>
int con,sum,j,num,pant,conpag;
char pausa;
void main()
{
clrscr();
fflush (stdin);
gotoxy (20,12);
printf("Introduce un N£mero: ");
scanf ("%d", &num);
while (num < 1)
{
clrscr();
fflush (stdin);
gotoxy (12,12);
printf("Introduce un N£mero correcto (mayor o igual que 1): ");
scanf ("%d", &num);
}
con=0;
sum=0;
j=7;
pant=0;
conpag=0;
clrscr();
if (num>=j)
{
printf ("\t\t Lista de los m£ltiplos de siete entre 1 y %d.\n",num);
while (j<=num)
{
pant++;
if (pant<=219)
{
printf ("\t%d",j);
con++;
sum=sum+j;
j=j+7;
}
else
{
conpag++;
pant=0;
printf ("\n P gina: %d.\t\t\t\t\tPulsa ENTER para continuar...",conpag);
fflush (stdin);
scanf ("%c",&pausa);
clrscr();
printf ("\t\t Lista de los m£ltiplos de siete entre 1 y %d.\n",num);
}
}
conpag++;
gotoxy (1,25);
printf (" P gina: %d.\t\t\t\t\tPulsa ENTER para continuar...",conpag);
fflush(stdin);
scanf("%c",&pausa);
clrscr();
gotoxy (20,11);
if (con==1)
{
printf("Hay %d m£ltiplo de siete.",con);
}
else
{
printf("Hay %d m£ltiplos de siete.",con);
}
gotoxy (20,12);
printf("Su suma es: %d",sum);
fflush(stdin);
scanf("%c",&pausa);
}
else
{
clrscr();
gotoxy (20,11);
printf("Hay %d m£ltiplos de siete.",con);
gotoxy (20,12);
printf("Su suma es: %d",sum);
fflush(stdin);
scanf("%c",&pausa);
}
clrscr();
}