php hit counter

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PROBLOM IN PROGRAMMING code 2011
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support
#2
Dear Student,
This program is just like a game where a Die is rolled. We know that a Die consists of 6 numbers from 1 to 6 on its each different face. Here in this program, the objective is to find the number of times each face will come up when that die is rolled 600000 times. Let us look at the logic behind the loop which you are finding dificult to understand.

Code:
for (roll=1;roll<=600000;roll++) frequency[1+rand()%6]++;


In the loop declaration, you can see that loop limit is less than equal to 600000, which means that this loop will be executed 600000 times. In other words, this limits describes the number of times the Die will be rolled. Now lets come to second statement of the above code. We know that a die can only have 6 faces. when the 1+rand()%6 is executed, it always returns a value less than or equal to 6 becuase this value will represent the value of each face of the die.
Reply


Messages In This Thread
PROBLOM IN PROGRAMMING code 2011 - by sana.pari - 04-24-2011, 04:42 PM
PROBLOM IN PROGRAMMING code 2011 - by Support - 04-24-2011, 04:43 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  ASCII code is binary numbers of 0 and 1 in C++ 2012 Vuhelper 0 2,330 01-04-2012, 10:41 PM
Last Post: Vuhelper
  int x[10]; x[0]= 1; x[1]=2; if following code is executable in C++ 2012 Vuhelper 0 1,981 01-04-2012, 10:17 PM
Last Post: Vuhelper
  array project code c++ 2011 Vuhelper 0 1,328 12-10-2011, 06:32 PM
Last Post: Vuhelper
  factorial in C++ code 2011 Vuhelper 0 1,006 12-10-2011, 06:31 PM
Last Post: Vuhelper
  stack during function call in C++ 2011 Vuhelper 0 2,078 11-05-2011, 05:05 PM
Last Post: Vuhelper
  What is the Thing Queue? in c++ 2011 Vuhelper 0 1,835 11-05-2011, 05:02 PM
Last Post: Vuhelper
  ASCII to char conversion code in C++ 2011 Vuhelper 0 1,776 11-05-2011, 05:01 PM
Last Post: Vuhelper
  How to write a summation in a sequence? C++ 2011-12 Vuhelper 2 1,428 09-19-2011, 04:53 AM
Last Post: Xpert
  GetPixel problem in c++ 2011-12 Vuhelper 0 2,551 09-18-2011, 07:12 PM
Last Post: Vuhelper
  C++ with loop code 2011-12 Vuhelper 0 1,027 09-18-2011, 07:09 PM
Last Post: Vuhelper

Forum Jump:


Users browsing this thread: 1 Guest(s)
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support