Implement a function that counts the number of negative integers in a two-dimens
ID: 3839866 • Letter: I
Question
Implement a function that counts the number of negative integers in a two-dimensional array with 100 rows and 100 columns. The function takes a two-dimensional array of int and returns the number of negative numbers in it. A declaration of the function is shown below.int countNegatives(int a[100][100]);
Implement a function that counts the number of negative integers in a two-dimensional array with 100 rows and 100 columns. The function takes a two-dimensional array of int and returns the number of negative numbers in it. A declaration of the function is shown below.
int countNegatives(int a[100][100]);
int countNegatives(int a[100][100]);
Explanation / Answer
int countNegatives(int a[100][100])
{
int i,j,count=0;
for(i=0; i<100; i++)
for(j=0;j<100;j++)
{
if(a[i][j]<0)
{
count++;
}
}
return count;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.