+ 5
why this small code is not working?
i have to options: 1- use a counter c and use it in ( b for loop). 2- use a counter sum and then pass it in two for loops ( in this code). i have tried the 2 ways and i get bad results. https://code.sololearn.com/cKIuSU9SRtCJ/?ref=app
3 Respostas
+ 7
First of all, you have used the concept of dynamic initialization i.e. you have directly declared the i and j variables in for loop which is not supported in C as C is procedure oriented language.
Declare i and j along with a and b.
Then remove the int from both i and j.
Then see, the program will run.
But I don't understand, exactly what your program is doing ??
Why have you used a pointer sum ??
+ 4
Part A
1. Initialize pointer sum as pointing to NULL.
2. Declare a variable as location of the pointer.
3. Assign your pointer to point to the LOCATION of the variable.
4. Update the pointed variable by using parathese (*sum)
5. Print *sum not sum
6. %d not %i
B. Fixed for your reference
https://code.sololearn.com/cK2bfJ2SNRX6/?ref=app
C. You need to play with these example codes about pointer.
https://www.sololearn.com/learn/C/2933/
+ 4
In the 8th line you've written sum instead of *sum