seergiomv

Ejercicio 8.3

Nov 22nd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int MesSiguiente(int mes) {
  4.     // Se devuelve -1 si el mes no es un numero malido
  5.     if (mes < 1 ||  mes > 12)
  6.         return -1;
  7.    
  8.     int tmp = mes + 1;
  9.     if (tmp > 12)
  10.         tmp = 1;
  11.  
  12.     return tmp;
  13. }
  14.  
  15. int main() {
  16.     int x;
  17.  
  18.     printf("Introduzca un numero de mes: ");
  19.     scanf("%d", &x);
  20.  
  21.     printf("El siguiente mes es %d\n", MesSiguiente(x));
  22.  
  23.     return 0;
  24. }
Add Comment
Please, Sign In to add comment