Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

Odd-Even-inator with function in C

#include<stdio.h>

int isEven(int);

int main(void) {
  int n, x, a;
  
  int array[n];
  
  printf("Enter n: ");
  scanf("%d", &n);
  
  int elem[n];
  
  for(x=0; x<n; x++){
    
  printf("Enter value #%d: ", x+1);
  scanf("%d", &elem[x]);
    
   a = elem[x];
    
    if(isEven(a))
    printf("%d is even
",a);
    
    else
      printf("%d is odd
",a);
}
    return 0;
}

int isEven(int n) {
    return n % 2 == 0;
}
 
PREVIOUS NEXT
Tagged: #function #C
ADD COMMENT
Topic
Name
8+9 =