Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    cnt prefix in java?

    Im just wondering what cnt means? A java trainer I am working on put it in the answer to a puzzle that I was working on, and i dont know what it means..

    static int factorial(int n)
    {
    int cnt = 2;
    int fact = 1;
    while(cnt <= n)
    {
    fact *= cnt;
    cnt++;
    }
    return fact;
    }

    any help would be appreciated. thanks.

  2. #2
    Regular Coder anarchy3200's Avatar
    Join Date
    Mar 2003
    Location
    England
    Posts
    261
    Thanks
    0
    Thanked 1 Time in 1 Post
    it looks like it is just the name of the integer

    the 'int' specifies the data type of the variable - integer
    the 'cnt' is the name of it
    then you set the value to the variable

    its the same with int fact - its just the variable name

    Hope this helps
    Mike

  3. #3
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks a lot for clearing that up.

  4. #4
    Regular Coder
    Join Date
    Oct 2004
    Location
    England
    Posts
    282
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yup, as anarchy said, i'd imagine cnt is a short way of saying count since you're incrementing every time you iterate through the while loop


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •