Ask your own question, for FREE!
Computer Science 9 Online
OpenStudy (anonymous):

can someone explain how this code works i kind of have anidea but just want to make sure void printBig(int a[]) { int count, i=0; bool x=true; count=MAX_DIGITS-1; while(x) { if(a[count]!=0) x=false; //else if(count==MAX_DIGITS-1) //x=false; else //i++; count--; } for(i=count;i>=0;i--) cout<

OpenStudy (anonymous):

first of all, u need to have let the separately, is //else if (count = AX_DIGITS-1) a comment? and others that look the same, after then we can proceed

OpenStudy (espex):

Removing the comments from within the while loop, and assuming MAX_DIGITS is equal to your array size, this function takes an integer array and passes it into the while loop where it has two tests. The first test looks to see if the index pointed to by a[count] is not equal to 0, so assuming there is a value within that index of non-zero, 'x' is set to false, decrement count by 1, and the loop exits. Your second test, the else if, looks to see if count is equal to MAX_DIGITS-1, which is the same value you give it on line 5. When it sees that the condition is true, 'x' is set to false, decrement count by 1, and the while loop exits. The for loop at the end will print out the values held within the array from a[MAX_DIGITS-2] through a[0]. This does not appear to be useful code, and if I am following it accurately, I would guess that it is not working as you thought, which is why you have commented out so many lines.

OpenStudy (konradzuse):

This code doesn't work.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!