Question: #include #define MAXIND 1 0 0 / * * return the first index containing negative value, or - 1 * / size _ t find

#include
#define MAXIND 100
/*
* return the first index containing negative value, or -1
*/
size_t find_neg(int arr[], size_t n)
{
for(size_t j =0; j < n; ++j)
if (arr[j]<0)
return j;
return -1;
}
int main(void)
{
int a[MAXIND];
/* initialize array to squares of integers */
for(size_t i =0; i < MAXIND; ++i)
a[i]= i*i;
a[17]=-a[17]; /* make a[17] negative */
printf("First negative integer found at index =%zu
",
find_neg(a, MAXIND));
return 0;
}
how to make the out put negative value

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

include stdio h define MAXIND 20 Function to find the first index c... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!