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 belowhere 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started