Note the following piece of code:
int func (myval)
int myval;
{
//statements...
}
The code below, seems to me the equivalent:
int func (int myval)
{
//statements...
}
My questions are:
1. What is the difference between the two pieces of code ?
2. Are there any advantages...
James,
Yes, that would have been a good case.
It's acually part of an algorithm used
to draw a random graphic. The random
function in this case determines on
which axis a certain part of the graphic
will be drawn. In fact a problem is that
the chances of each outcome are not
equally...
2ffat,
Our results are very similar.
When using random(100) > 50 the chances
of each outcome are equally spread between
"positive" and "negative" numbers. Meaning that
sometimes the positive outcome slightly surpasses
the negative outcome and vice verca.
Please note the following fault in...
tsh73,
I think you meant that -1 has approximately 70%
probability while 1 has approximately 30% probability.
2ffat has shown a piece of code which I think demostrates
this.
Regarding the parameter passed to random:
As itsgsd pointed out, it defines the range.
e.g. random(5) will give...
The following is a small program which
generates random numbers which can be
either 1 or -1:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main(void)
{
int i;
randomize();
printf("Ten random numbers of either -1 or 1\n\n");
for(i=0; i<10; i++)...
After reading all your suggestions, I came up with the following code. I created another class called studentCls which is basically an array of the student class created previously. It also includes some other functions to populate the array and display them. I split the code as shown below...
Lately I have been experimenting with splitting classes in header files and cpp files. As far as I knew, the basic concept when splitting classes in header files and cpp files was the following:
header file --> declaration of class
cpp files --> implimentation / definition of class
However...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.