C Program Display and Count Odd Numbers in Array

By | March 15, 2020

C Program Display and Count Odd Numbers in Array

 /* C Program to display and count all
    odd numbers in array
       www.EasyCodeBook.com
 */
#include <stdio.h>

int main()
{
  int array[100],i,n, count=0;

  printf("Enter number of elements in array = ");
  scanf("%d", &n);

  printf("Enter %d numbers in array\n", n);

  for (i = 0; i < n; i++)
      scanf("%d", &array[i]);
	    
	      
	  for (i = 0; i < n; i++)
      {
	    if(array[i]%2==1)
		  {
		   printf("%d is Odd Number\n",array[i]);
		   count++;
		  }
	  }
	  
	  printf("The count of all Odd numbers in array is %d",count);     
  return 0;
}

Output

Enter number of elements in array = 5
Enter 5 numbers in array
6
7
8
9
10
7 is Odd Number
9 is Odd Number
The count of all Odd numbers in array is 2

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *