Question: I need a help to correct this code! There are 4 errors and they are the same. The error is warning: ignoring return value of

I need a help to correct this code! There are 4 errors and they are the same. The error is

warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result], which I marked below

here is the code

#include #include

struct make { int ai, bi; };

int people(struct make house[], int low, int high, int l, int h){

int num = 0; int arrnum = 0;

for(int i=low;i

{

for(int j=0; j;> { if (abs(i - house[j].bi) => { arrnum += house[j].ai;

} } if (arrnum > num) { num = arrnum; } } return num; }

int main(){

int l, h;

printf(\"the number of house: \"); scanf(\"%d\", &l); //warning: ignoring return value of 'scanf', declared with attribute warn_unused_result printf(\"distance: \"); scanf(\"%d\", &h); //warning: ignoring return value of 'scanf', declared with attribute warn_unused_result

struct make house[l]; int low = -1, high = -1;

for(int i=0; i { printf(\"Enter %d: \", i+1); scanf(\"%d\", &house[i].bi); //warning: ignoring return value of 'scanf', declared with attribute warn_unused_result printf(\"Enter the numof ppl %d: \", i+1); scanf(\"%d\", &house[i].ai); //warning: ignoring return value of 'scanf', declared with attribute warn_unused_result

if (low == -1 || low > house[i].bi) { low = house[i].bi; }

if (high

{

high = house[i].bi;

} return 0; }

printf(\"The : %d \", people(house, low, high, l, h));

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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!