Negative Number

QUESTION

Print all the negative elements in an array.

“TESTCASE_1”: “5\n-8 89 -48 -71 36\n###—###SEPERATOR—###—\n-8 -48 -71”, “TESTCASE_2”: “12\n-1 0 -5 4 -2 2 3 1 4 2 -10 -3\n###—###SEPERATOR—###—\n-1 -5 -2 -10 -3”, “TESTCASE_3”: “2\n1 -2\n###—###SEPERATOR—###—\n-2”, “TESTCASE_4”: “0\n###—###SEPERATOR—###—\n0”, “TESTCASE_5”: “0\n###—###SEPERATOR—###—\n0

ANSWER

#include <stdio.h>

#define MAX_SIZE 100

int main()
{
    int arr[MAX_SIZE]; 
    int i, N;

 
    
    scanf("%d", &N);


    
    for(i=0; i<N; i++)
    {
        scanf("%d", &arr[i]);
    }

     
    for(i=0; i<N; i++)
    {
       
        if(arr[i] < 0)
        {
            printf("%d ", arr[i]);
        }
    }

    return 0;
}
Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.