0
Can you please describe every steps why the answer is 16
#include <stdio.h> int f(int b[][4]) { int i,j,s=0; for(j=0;j<4;j++) { i=j; if(i>2) i=3-j; s+=b[i][j]; } return s; } main( ) { int a[4][4]={{1,2,3,4},{0,2,4,5},{3,6,9,12},{3,2,1,0}}; printf("%d\n",f(a)); }
7 odpowiedzi
+ 2
check it now
+ 1
you can use the print statement to print the value inside the if statement in the function to see what's been added to "s" since that's what's getting returned
+ 1
Example please
+ 1
you see what's happening there now right
https://code.sololearn.com/c8rYfHwX0F4J/?ref=app
0
why not put it on code playground, and try print every steps, that will improve your debugging skills and help you understand the code better than if a user explain em to you, try that 1st and if you still don't get it i won't mind explaining though
0
Thank you . how to debug . i am a new progammer
0
// Created by ✳AsterisK✳
#include <stdio.h>
int f(int b[][4])
{ int i,j,s=0;
for(j=0;j<4;j++)
{ i=j;
if(i>2) // i cant understant this . how it work
i=3-j;
s+=b[i][j];
printf(" %d ",s);
}
return s;
}
int main( )
{ int a[4][4]={{1,2,3,4},{0,2,4,5},{3,6,9,12},{3,2,1,0}};
printf("%d\n",f(a));
}