Created
December 4, 2015 16:01
-
-
Save wero1414/8aedf97b7aff55c4e491 to your computer and use it in GitHub Desktop.
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> | |
#include <stdlib.h> | |
#include <math.h> | |
/* run this program using the console pauser or add your own getch, system("pause") or input loop */ | |
int suma(int); | |
int mult(int); | |
void genera(int, int, int); | |
int x,y,z,a,li,ls; | |
int main() { | |
int salir; | |
do{ | |
int op; | |
printf("Bienvenido\n\t Selecciona la funcion a desarrollar\n"); | |
printf("1 Sumar N numeros\n"); | |
printf("2 Multiplicar N numeros\n"); | |
printf("3 Generar N numeros aleatorios\n"); | |
scanf("%d",&op); | |
switch(op) | |
{ | |
case 1: | |
printf("Bienvenido a suma, cuentos numeros sumaras?"); | |
scanf("%d",&x); | |
printf("La suma es: %d\n",suma(x)); | |
break; | |
case 2: | |
printf("Bienvenido a Multiplicacion, cuentos numeros multiplicaras?"); | |
scanf("%d",&y); | |
printf("La multiplicacion es %d\n",mult(y)); //Multiplica | |
break; | |
case 3: | |
printf("Bienvenido a numero aleatorio\n\tIngresa Cuantos numeros aleatorios necesitas"); | |
scanf("%d",&z); | |
printf("ingrese el limite inferior y posteriormente el Superior"); | |
scanf("%d%d",&li,&ls); | |
printf("Sus numeros son:\n"); | |
genera(z,li,ls); //funcion aleatorio | |
break; | |
default: | |
printf("\nIngrese seleccion valida\n"); | |
break; | |
} | |
printf("Desea repetir el programa?\nSi=1\tNo=0"); | |
scanf("%d",&salir); | |
} | |
while(salir); | |
return 0; | |
} | |
int suma(int s) | |
{ | |
int i; | |
int su; | |
int suma; | |
suma=0; | |
for(i=1;i<=s;i++) | |
{ printf("Ingrese numero %d a sumar ",i); | |
scanf("%d",&su); | |
suma=su+suma; | |
} | |
return suma; | |
} | |
int mult(int m) | |
{ | |
int i1; | |
int mu; | |
int multi; | |
multi=1; | |
for(i1=1;i1<=m;i1++) | |
{ | |
printf("Ingrese numero %d a multiplicar ",i1); | |
scanf("%d",&mu); | |
multi=mu*multi; | |
} | |
return multi; | |
} | |
void genera(int p,int o, int l){ | |
int q; | |
srand(time(NULL)); | |
int a; | |
int m; | |
for(q=1;q<=p;q++){ | |
a=rand(); | |
m=o+a%(l-o+1); | |
printf("%d\n\n",m); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment