![]() |
| ||
| display array element with passing value...no undesstand~help okay, here is the code my teacher gave...but i do not understand some part... #include <stdio.h> |
| ||
| Re: display array element with passing value...no undesstand~help What part to you not understand? |
| ||
| Re: display array element with passing value...no undesstand~help statement 11th and 38th...i think that for some sort to arrange the value printed. But no understand how it work. Thx for reading my post |
| ||
| Re: display array element with passing value...no undesstand~help Those statements are used to print a newline after 10 numbers are printed in a row. % is the modulus operator. a%10is 0 for numbers like 10, 20, and so on. So after the 10th number, the rest of the array is printed in a newline. The same happens after printing the 20th number and so on. Comment out those lines and see how the output changes. The values printed will be the same, but the output will be in a single line. |
| ||
| Re: display array element with passing value...no undesstand~help if(!(a%10)) but what is not (a%10)? And statement 24th which is: if(!((a-1)%20)) Why it %20 instead of 10. When i put replace it to 10 it just show 5 value in row then newline. Also the statement 38th which is: if(!(num%10)&& !newline) I removed the newline and it come out that output is became messy. I do not know why. Thx for helping me. |
| ||
| Re: display array element with passing value...no undesstand~help Quote:
Is looking for when the result of the operation a % 10 would be 0, however 0 inside an if statement will never execute since in C, 0 is considerate FALSE. Hence the ! added inside the if() to force its execution. With this information in hand, think about the other examples you're querying about. |
| ||
| Re: display array element with passing value...no undesstand~help Yea...i knew why it %20 because it increment is 2, instead of 1....Thx ^^ |
| All times are GMT -4. The time now is 11:13 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC