Lee_assig16a - if(n==2 cout<<1<<2<<endl...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 //Cheu Lee Assig_16 #include <iostream> #include <cmath> #include <cstdlib> using namespace std int main() { int choice, flag=0 cout.setf(ios::fixed) cout.precision(2) cout<<"What would you like to do?"<<endl cout<<"Select 1, 2, or 3: "<<endl cout<<"+----------------------------------------------+\n" cout<<"| 1. Prime Number Program |\n" cout<<"| 2. Greatest Common Factor Program |\n" cout<<"| 3. Exit |\n" cout<<"+----------------------------------------------+\n" if (choice==1){ int i, j, n cout<<"Enter a positive number and the prime numbers will generate."<<endl cin>>n if (n==1) cout<<n<<endl
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if (n==2) cout<<1<<2<<endl if (n>=3){ for (int j=n j<=n j++){ for (int i=2 i<=sqrt(double(n)) i++)} } if (n%i==0) flag=1 } if (flag=0) int j cout<<"The Prime numbers are: "<<j<<endl break } if (choice==2){ int x, y, factor cout << "This program allows calculating the GCF.\n"<<endl cout << "Please enter two positive intergers.\n"<<endl cout << "First interger: "<<endl cin >> x cout << "Second interger: "<<endl cin >> y factor=(y&&x%2||3||4||5||6||7||8||9) cout << "The Greatest Common Factor of " << x << " and " << y << " is " << factor << endl } return 0...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online