Why am I getting neither output nor errors? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why am I getting neither output nor errors?

I am trying to add and sub 1 from alternating array elements. But there is no output. Please tell if any change in code is required. https://code.sololearn.com/cVOL96BFPMPc/#c

31st Dec 2018, 7:43 AM
Parth Salat
Parth Salat - avatar
2 Answers
+ 5
int arr[10] should be declared outside of main() if you want it to be a global variable. Lines 11/13 are function declarations, not function calls. Call a function with function(), not with int function(). Both of your functions are declared as int, but they don't return any integers. Either return an int or set their return value to void.
31st Dec 2018, 9:07 AM
Anna
Anna - avatar
+ 6
In addition to what others had explained, you can alternatively change your fun1 & fun2 declaration to allow them to accept the array as function argument. Anyways, you still have to decide whether to return something (int), or don't return anything (void), in this case however, I don't see any importance for those functions to return an int value, since you are only modifying the array elements' values, and printing them to the screen. int fun1(int []); int fun2(int []); Yet again, you call a function with its name (and arguments if any, but without the return type) as follows: fun1(arr); fun2(arr); Hth, cmiiw
31st Dec 2018, 9:32 AM
Ipang