Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Using ternary and summing array
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="flebber, post: 4393311"] [i] Thank You Jean-Christophe, I like the way you use the define as I think it makes it clear and readable. James thanks for explaining that. I had the feeling I was doing it wrong but wasn't quite sure where it was going wrong. So this declares my array as a global value. I can then assign a value(size of array) to it locally. This would then mean that if I had 5 different functions they could all have their own size declared of array a[] locally? May not be the best idea but I could do this? With this skeleton shouldn't I declare int a[1000], ? [i][i] Working on it... not close yet but will get there, having issues with local variables. #include <stdio.h> #define limit 1000; int two_pointer_args(int, int); /* function using two ints */ int main() { two_pointer_args(int i, int j); i, j = 0; int i_total=0; int j_total=0; { while (i < limit) { if ((i % 3 == 0)|| (i % 5 == 0)) { i_total+=i; } else { j_total = i + j; } i++; } printf(" The sum of i was %d and the sum of j was %d\n", i_total, j_total); } return 0; } Thanks for all the help Sayth.[/i][/i][/i] [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Using ternary and summing array
Top