Created
March 8, 2023 10:47
-
-
Save alphanetEX/509fee019b06f4cddf1542867b6062cd to your computer and use it in GitHub Desktop.
manifiesto algoritmos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
/* ingrese numeros mayores a 0 y vamos a calular el | |
- promedio de los numeros impares | |
- la cantidad de numeros mayoyes que a 24 y pares | |
- la sumatoria de los numeros primos | |
*/ | |
void cargar(int vec[], int dim){ | |
int cont=0, num=0, contPar=0, contImp=0, itemb=0; | |
while(cont < dim){ | |
printf("Ingrese un numero: "); | |
scanf("%d", & num); | |
if(num%2 == 0 ){ | |
vec[cont] = num; | |
contPar++; | |
} else if( num >= 24 && (num%2 !=0)){ | |
vec[cont]; | |
itemb++; | |
} else if(num%2 != 0) { | |
vec[cont] = num; | |
contImp++; | |
} | |
cont++; | |
} | |
//Contador de pruebas | |
printf("promedio de numeros impares: %d \n", contImp); | |
printf("numero mayores a 24 y impares: %d \n", itemb); | |
} | |
void second(){ | |
int cont=0, num=0, contPar=0, contImp=0, itemb=0, cont_primos=0, cant_primos=0; | |
printf("Ingrese un numero: "); | |
scanf("%d", & num); | |
while(num !=0){ | |
if(num%2 == 0 ){ | |
contPar++; | |
} else if( num >= 24 && (num%2 !=0)){ | |
itemb++; | |
} else if(num%2 != 0) { | |
contImp++; | |
} | |
cont_primos=0; | |
for (int i = 1; i <= num; i++){ | |
if(num % i == 0){ | |
cont_primos++; | |
} | |
} | |
if(cont_primos ==2){ | |
printf("Es primo \n"); | |
cant_primos++; | |
} | |
printf("Ingrese un numero: "); | |
scanf("%d", & num); | |
} | |
printf("promedio de numeros impares: %d \n", contImp); | |
printf("numero mayores a 24 y impares: %d \n", itemb); | |
printf("la cantidad de numeros primos es: %d \n", cant_primos); | |
} | |
int main(){ | |
second(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment