Computer Science, asked by anaghadevadas0084, 4 months ago

find sum and count of negative numbers from a set of n numbers c program​

Answers

Answered by Anmolchaudhary1
0

Answer:

Jejdhdhiirirueueueue

Answered by dreamrob
0

Program in C:

#include<stdio.h>

#include<conio.h>

int main()

{

int n , sum = 0 , count = 0 ;

printf("Enter numbers of elements : ");

scanf("%d" , &n);

int A[n];

printf("Enter elements in the array : \n");

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

{

 scanf("%d" , &A[i]);

}

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

{

 if(A[i] < 0)

 {

  sum = sum + A[i];

  count++;

 }

}

printf("Sum of negative numbers : %d \n" , sum);

printf("Count of negative numbers : %d \n" , count);

return 0;

}

Output:

Enter numbers of elements : 10

Enter elements in the array :

1

-2

3

-4

5

-6

7

-8

9

-10

Sum of negative numbers : -30

Count of negative numbers : 5

Similar questions