Originally Posted by
Amberlampz
Not quite. I'm looking to print out the value of the mode of an array and how many times that value occurs. I have the latter, but I'm not sure (syntactically) how to print out the value itself. Apologies if I wasn't clear about that.
I'm still not clear on what you can't figure out how to print.
Code:
int x = putsomevaluehere;
printf( "x is %d\n", x ); /* print whatever value x has */
So, assuming you actually have a value stored some place, or can figure out how to store it some place, you should be able to print that value out. So:
Code:
int data[] = { 1, 2, 3, 1, 1, 2, 5 }; /* <--- has v */
int mode[] = { 0, 3, 2, 1, 0, 1 }; /* 0 0s, 3 1s, 2 2s, etc... */
int x;
for( x = 0; x < 6; x++ ) /* because we happen to have six slots in our array */
printf( "mode[ %d ] has the value of %d\n", x, mode[ x ] );
As I illustrated earlier.
Quzah.