luc055.c (940B)
1 /* Twenty-five numbers are entered from the keyboard into an array. Write a program to find out how many of them are positive, how many are negative, how many are even and how many odd. 2 */ 3 4 /* Let Us C, Chap- 13 (Arrays), Qn No.: B(a) */ 5 6 /* This file is auto-generated by a bot. */ 7 /* This code is not compiled; it is for reference only. */ 8 9 10 #include <stdio.h> 11 #include <math.h> 12 #include <stdlib.h> 13 14 int main() 15 { 16 int arr[25], i; 17 int pos = 0, neg = 0, even = 0, odd = 0; 18 19 printf("Enter 25 integers:\n"); 20 for (i = 0; i < 25; i++) 21 { 22 scanf("%d", &arr[i]); 23 24 if (arr[i] > 0) 25 pos++; 26 else if (arr[i] < 0) 27 neg++; 28 29 if (arr[i] % 2 == 0) 30 even++; 31 else 32 odd++; 33 } 34 35 printf("\nResults:\n"); 36 printf("Positive: %d\n", pos); 37 printf("Negative: %d\n", neg); 38 printf("Even: %d\n", even); 39 printf("Odd: %d\n", odd); 40 41 return 0; 42 }