Good grief! Have you really been told to use eight spaces, because your indentation is really difficult to read. And separate out your code a bit. Not
for(i=0;i<n;i++) // line 2 of second block
but
for (i = 0; i < n; i++) Can you really use scanf with a number as its argument? I am sure that is wrong.>
Campbell Ritchie wrote:
Can you really use scanf with a number as its argument? I am sure that is wrong.
Correct. This is definitely wrong. With C/C++, just like Java, the result of the assignment is the value of the assignment. This means that the value of the expression, which includes a random component, is being passed to the scanf() function. Depending on what is passed, this call will likely seg fault.
Campbell Ritchie wrote:
Can you really use scanf with a number as its argument? I am sure that is wrong.
Correct. This is definitely wrong. With C/C++, just like Java, the result of the assignment is the value of the assignment. This means that the value of the expression, which includes a random component, is being passed to the scanf() function. Depending on what is passed, this call will likely seg fault.
Henry
Sorry about that I have never use the random numbers generator in C and i thought that scanf will input a random numbers in scanf then output a random numbers ( random page sequences size enter like 1 2 3 4 5 1 1 1 in the array) when i keep clicking run each time this will output a different numbers in each array.
Creativity is allowing yourself to make mistakes; art is knowing which ones to keep. Keep this tiny ad: