Even or Odd

    0

    0

    Giovanny Gongora

    Codiga's C Recipes

    check whether a number entered by the user is even or odd

    #include <stdio.h>
    
    int ifEvenOrOdd() {
      int num;
      printf("Enter an integer: ");
      scanf("%d", &num);
      // true if num is perfectly divisible by 2
      if(num % 2 == 0)
        printf("%d is even.", num);
      else
        printf("%d is odd.", num);
      return 0;
    }
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.