In this article, we are going to learn How to print all negative elements of an array in C++.
How to print all negative elements of an array in C++
#include <iostream>
#define MAX_SIZE 250
using namespace std;
int main()
{
int Array[MAX_SIZE];
int Size;
cout<<"Please enter size of the array (Max 250): ";
cin>>Size;
cout<<"Please enter elements in array: ";
for(int i=0; i<Size; i++)
{
cin>>Array[i];
}
cout<<"All negative elements in array are:";
for(int i=0; i<Size; i++)
{
if(Array[i] < 0)
{
cout<<Array[i];
}
}
return 0;
}
Output
Please enter size of the array (Max 250): 15 10
Please enter elements in array: -12
15
13
-10
-15
-20
-3- 0
-40
-50
80
All negative elements in array are:-12-10-15-20-30-40-50
split Pandas DataFrame column by single Delimiter
Output