Get Update on recent Technology & Programming

Tuesday, 7 November 2017

C Program to count even and odd numbers in an array

Posted by   on Pinterest


 #include<stdio.h>  
 #define SIZE 10  
 int main(void)  
 {  
      int arr[SIZE],i,even=0,odd=0;  
      for(i=0; i<SIZE; i++)  
      {  
           printf("Enter a value for arr[%d] : ",i);  
           scanf("%d",&arr[i]);  
           if(arr[i]%2 == 0)  
                even++;  
           else  
                odd++;  
      }  
      printf("Even numbers=%d, Odd numbers=%d\n",even,odd);  
      return 0;  
 }  

No comments:
Write comments

Hey, we've just launched a new custom color Blogger template. You'll like it -
Join Our Newsletter