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...

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....

This article has been dead for over six months. Start a new discussion instead.