1. Ask the User for his or her name.
  2. Display a Menu asking the user.
    a. Would you Like To Print all of the prime numbers from 3... N?
    b. Would you like to quit this program?
  3. If the User selects to print the prime numbers. Ask for the user to enter a value. Then find and print all of the primes to that value. Along with a message describing displaying the users name and what value they chose.

This is what I'm supposed to for the program but I'm not really sure how to do the second step.

So far all I have is this:

#include <iostream> 
using namespace std; 

int main (){
    int name; 

    cout << "Hello, What is your name?" << endl; 
    cin >> name;

    return 0;
}

Not much, is it? First, go to Wikipedia and read the article on prime numbers and the Sieve of Aristhostenes. We don't do your homework for you, and generating the prime numbers as specified in the SOW (statement of work) is the biggest part of this exercise.

Well, I did this but I'm doing something wrong.

#include <iostream> 
using namespace std; 

int main (){
    int name;  

    int 2 = prime numbers; 
    int 4 = quit; 


    cout << "Hello, What is your name?" << endl; 
    cin >> name;


{ 
    cout << "Would you like to print all prime numbers from 3... N?" << endl; 
    cin << 2; 
    cout << "Would you like to quit this program?" << endl; 
    cin << 4; 
} 


    return 0;
}

DO NOT give your variables numeric names! Instead of '2', use 'two', etc. Also, your code is not valid for the variable initialization. Please provide the EXACT code you used. If this is it, then you need to go back to the book...

the correct syntax of cin is

cin>>variable_name

also take a look at the variable naming convention in c++
http://mathbits.com/MathBits/CompSci/DataBasics/naming.htm

you can't directly assign a value in cin statement

to take user input

dim num as int;
cin>>num;

to assign values directly

dim num as int;
num = 4;

mridul.ahuja: What language is this again? Because that certainly isn't C++ declaration syntax. I think you're thinking of VB.Net, except that cin and the input operator aren't in VB....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.