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)); }

9th Dec 2019, 7:35 AM
Naem Azam
Naem Azam - avatar
7 ответов
+ 2
check it now
9th Dec 2019, 7:58 AM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 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
9th Dec 2019, 7:43 AM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 1
Example please
9th Dec 2019, 7:44 AM
Naem Azam
Naem Azam - avatar
+ 1
you see what's happening there now right https://code.sololearn.com/c8rYfHwX0F4J/?ref=app
9th Dec 2019, 7:46 AM
✳AsterisK✳
✳AsterisK✳ - avatar
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
9th Dec 2019, 7:38 AM
✳AsterisK✳
✳AsterisK✳ - avatar
0
Thank you . how to debug . i am a new progammer
9th Dec 2019, 7:42 AM
Naem Azam
Naem Azam - avatar
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)); }
9th Dec 2019, 7:54 AM
Naem Azam
Naem Azam - avatar