Write a program to count the total number of even and odd elements in an array
- #include <stdio.h>
- int main()
- {
- int arr[100];
- int i, n;
- int even=0, odd=0;
- printf("Enter the number to be stored in the array : ");
- scanf("%d", &n);
- printf("Enter %d elements in the array : ", n);
- for(i=0; i<n; i++) {
- scanf("%d", &arr[i]);
- }
- for(i=0; i<n; i++) {
- if(arr[i]%2 == 0) {
- even++;
- }
- else {
- odd++;
- }
- }
- printf("Total even elements: %d\n", even);
- printf("Total odd elements: %d", odd);
- return 0;
- }
একটি মন্তব্য পোস্ট করুন