Computer Science, asked by ananyaaspk, 8 hours ago

1) Write a program to enter the 20 numbers and
display the count of positive,​

Answers

Answered by nitishshaw720
0

Explanation:

/ C program to find the count of positive

// and negative integers in an array

#include <stdio.h>

// Function to find the count of

// positive integers in an array

int countPositiveNumbers(int* arr, int n)

{

int pos_count = 0;

int i;

for (i = 0; i < n; i++) {

if (arr[i] > 0)

pos_count++;

}

return pos_count;

}

/ / Driver program

int main()

{

int arr[] = { 2, -1, 5, 6, 0, -3 };

int n;

n = sizeof(arr) / sizeof(arr[0]);

printArray(arr, n);

printf("Count of Positive elements = %d\n",

countPositiveNumbers(arr, n));

return 0;

}

Similar questions