Results 1 to 7 of 7
  1. #1
    Cehk!'s Avatar
    Join Date
    Oct 2011
    Gender
    male
    Location
    NY
    Posts
    3
    Reputation
    10
    Thanks
    0
    My Mood
    Inspired

    Getting Started With C++ [Solved]

    Alright so im just starting C++ and im reading C++ without fear the second edition and i just really needed some basic help with understanding what do i have to do to print all the numbers from n1 to n2 where n1 and n2 are two numbers specified by the user. Im using the program dev-c++ as my compiler. Thanks

  2. #2
    258456's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    ghjghj
    Posts
    1,222
    Reputation
    18
    Thanks
    300
    My Mood
    Relaxed
    Well, you will first need to define n1 and n2 as an int variable sinice they will be integers:

    int n1, n2;


    Then you will use the cin function to get user input:

    std::cin>>n1;
    std::cin>>n2;

    Then you will want to print it, so you use the cout function:

    std:: cout<<"First number is: "<<n1<<"\nSecond number is: "<<n2;


    Keep us posted on your progress.

  3. The Following User Says Thank You to 258456 For This Useful Post:

    Cehk! (10-24-2011)

  4. #3
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    Quote Originally Posted by 258456 View Post
    Well, you will first need to define n1 and n2 as an int variable sinice they will be integers:

    int n1, n2;


    Then you will use the cin function to get user input:

    std::cin>>n1;
    std::cin>>n2;

    Then you will want to print it, so you use the cout function:

    std:: cout<<"First number is: "<<n1<<"\nSecond number is: "<<n2;


    Keep us posted on your progress.
    He wants to print all the numbers in the range of n1 and n2 (inclusive).

    Code:
    #include <iostream>
    #include <conio.h>
    using namespace std;
    void main()
    {
    int n1,n2;
    cout << "Enter 1st Number: ";
    cin >> n1;
    cout << "Enter 2nd Number: ";
    cin >> n2;
    for(int x = n1;x<=n2;x++) //Initialize x to the number stored in n1. Then loop while x is less than or equal to the number stored in n2. (x++ increments the value of x after each iteration.
    {
    cout << "Number is: " << x << endl;
    }
    _getch();
    }

  5. The Following User Says Thank You to Hassan For This Useful Post:

    Cehk! (10-24-2011)

  6. #4
    258456's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    ghjghj
    Posts
    1,222
    Reputation
    18
    Thanks
    300
    My Mood
    Relaxed
    Quote Originally Posted by Hassan View Post


    He wants to print all the numbers in the range of n1 and n2 (inclusive).

    Code:
    #include <iostream>
    #include <conio.h>
    using namespace std;
    void main()
    {
    int n1,n2;
    cout << "Enter 1st Number: ";
    cin >> n1;
    cout << "Enter 2nd Number: ";
    cin >> n2;
    for(int x = n1;x<=n2;x++) //Initialize x to the number stored in n1. Then loop while x is less than or equal to the number stored in n2. (x++ increments the value of x after each iteration.
    {
    cout << "Number is: " << x << endl;
    }
    _getch();
    }
    Oops, my bad, i misread his post.

  7. #5
    Cehk!'s Avatar
    Join Date
    Oct 2011
    Gender
    male
    Location
    NY
    Posts
    3
    Reputation
    10
    Thanks
    0
    My Mood
    Inspired
    Thanks for the help!

  8. #6
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    Np. Marked Solved.

  9. #7
    brandonl90's Avatar
    Join Date
    Apr 2011
    Gender
    male
    Location
    East Peoria,IL
    Posts
    15
    Reputation
    10
    Thanks
    0
    My Mood
    Amazed
    I was interested in making a Kill/Death Ratio Hack for Modern Warfare 3 can anyone help me get started? I just started to read some C++ books and i really need some professional help.

    Thank you

Similar Threads

  1. [C/C++ Tutorial] Getting Started With Visual C++/CLI
    By Hassan in forum Programming Tutorials
    Replies: 44
    Last Post: 04-02-2021, 07:16 PM
  2. [Help] Getting Started With Visual Applications [Solved]
    By xyddragon in forum C++/C Programming
    Replies: 4
    Last Post: 11-05-2011, 03:32 PM
  3. [Help] Getting started with Uniform Spatial Subdivision.
    By bubblesppf in forum C++/C Programming
    Replies: 0
    Last Post: 07-25-2011, 01:49 PM
  4. Getting started with Mw 2 MPGH
    By lolbie in forum Call of Duty Modern Warfare 2 Private Servers
    Replies: 27
    Last Post: 07-31-2010, 08:51 PM
  5. [Tutorial] Getting Started With a On Screen KeyBoard
    By CoderNever in forum Visual Basic Programming
    Replies: 11
    Last Post: 12-02-2009, 05:02 PM