Reply embedded...
> -----Original Message-----
> From: indian_cat_in [mailto:[EMAIL PROTECTED]
> Sent: Thursday, February 10, 2005 3:26 PM
> To: [email protected]
> Subject: [C-Paradise] Re: Still need help
>
>
> //I made only two changes description for the changes are given in the
> // respective positions
Since you ignoring most of what I posted, I am only going to repeat myself
again.
>
> #include <iostream.h>
> #include <stdlib.h>
> void main ()
> {
> unsigned int c,a,b;
> static int total[14];
> // static int is used to intialise the value of array "total" to 0
Don't use static just because it automatically initialized to zero.
'static' is *NOT* a convenient for auto initialization.
In a function 'static' retains its value between calls. If you use static
unjustly, you got yourself some serious bugs.
> //Incresed length of the array because last element is total[13],
Why? What do you really need to do?
> since max=13
> int max=13;
> randomize ();
> for (int i=1;i<=10;i++)
> {
> a=rand() % 6 + 1;
> b=rand() % 6 + 1;
> c=a+b;
> cout<<"Number rolled = "<<c<<endl;
> ++total[c];
> }
> for (int j=2;j<=12;j++)
> {
> total[max]=0;
^^^^^^^^^^^^
What's the point of this code where the next statement replaces tatal[max]
with total[j].
> total[max]=total[j];
> //here value of c is constant only value of j is varying
> cout<<j<<" "<<total[max]<<endl;
So you keep replacing total[max] with total[j] in a loop, but all you did
with total[max] is to print it out. Essentially, what you're doing is
simply print total[j] in a loop. All your assignment to total[max] are
superfluous.
for (...)
{
cout << j << " " << total[j] << endl;
}
What's your idea of introducing total[max] into the picture?
Shyan
>-----------------------------------------~-~>
CHECK THE ARCHIVE BEFORE POSTING!!!! Archive is available at
http://www.eScribe.com/software/C-Paradise/
>------------------------------------------_->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/C-Paradise/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/