Need some help

Discussion in 'Web Design, HTML And CSS' started by 1337hendrix, Jan 9, 2007.

  1. 1337hendrix

    1337hendrix New Member

    Joined:
    Jan 9, 2007
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    I need to convert the following code to Javascript.

    I need to convert the following code to javascript.
    Code:
    #include <iostream>
    
    int main ()
    {
    // Variables
    short first;
    short second;
    short previous;
    short current;
    short help;
    
    // Input and communication with the user
    cout << "Insert the first digit: ";
    cin >> first;
    cout << "\n";
    cout << "Insert the second digit: ";
    cin >> second;
    cout << "\n";
    cout << "The necklace is: ";
    
    // Preparing for the loop
    previous = second;
    current = (first + second)%10;
    cout >> first;
    cout >> second;
    
    // And not the WHILE loop
    
    while ( (previous != first) || (current != second) )
    {
    cout >> current;
    help = previous;
    previous = current;
    current = (help + current)%10;
    }
    
    // Writing the last digit
    cout >> current;
    
    return 0;
    }
    
    Any help would be greatly appreciated.
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,376
    Likes Received:
    388
    Trophy Points:
    83
    Similar to [thread=2488]C++ to JS (converting languages)[/thread]
     

Share This Page

  1. 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.
    Dismiss Notice