Created
February 26, 2016 12:50
-
-
Save jmramirezpro/3b9cb5e10b36fd869a61 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
/* | |
* NumeroN.c | |
* Ejercicios del Podcast Codigo Fuente - Programa 023 | |
* Escribe un programa que lea un número N mayor que 0 y | |
* que calcule la siguiente suma 1 + 2 + 3 + … + N | |
* Creado el 24 de feb. de 2016 | |
* Author: jmramirez | |
*/ | |
#include <stdio.h> | |
int main(void) | |
{ | |
int numero; | |
int suma = 0; | |
printf("Introduce un número: "); | |
scanf("%d", &numero); | |
while (numero > 0) { | |
suma = suma + numero; | |
numero = numero - 1; | |
} | |
printf("El resultado de la suma es: %d\n", suma); | |
return (0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment