Skip to content

This program prints every pair of prime numbers that are two apart up to the number inputted by the user.

Notifications You must be signed in to change notification settings

SofiSaR/C--_TwinPrime_Spring-2022

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Twin Prime Numbers Program

Feb 6, 2022

Objectives in Practice:

  • Develop, compile, and run a C++ program that requires C++ repetition control structures including the while loop, do - while loops, and/or for loops that utilize fundamental algorithms studied to perform common tasks, such as finding the max and min of a data set, counting, summing, tracking a previous value, searching and sorting, reading until EOF, etc. in programs to solve problems.

  • Transfer a program to the Unix server, use the G++ compiler to compile a program and execute a c++ program that you have written

  • Use the basic set of Unix commands to manipulate files.

The Instructions That Were Given for the Project:

  • Write a C++ program to print all the twin prime numbers below a certain given number. "A twin prime is a prime number (Prime Number Wiki) that is either 2 less or 2 more than another prime number—for example, either member of the twin prime pair (41, 43). In other words, a twin prime is a prime that has a prime gap (Prime Gap Wiki) of two. Sometimes the term twin prime is used for a pair of twin primes; an alternative name for this is prime twin or prime pair." See the Twin Prime Wiki

  • Your program should output the number of twin prime numbers found.

Make sure your program conforms to the following requirements:

  1. This program should be called TwinPrime.cpp

  2. Include the basic header in your program (Required Header Template)

  3. Accept the upper limit from the user (as an integer)

  4. Loop until the upper limit number entered is >=1

  5. Loop from 1 to the upper limit and print all twin prime numbers and the number of twin prime numbers found.

  6. Add comments wherever necessary

  • Follow the course coding standards outlined in Coding Standards_ (COP3363 Introduction to Programming in C++ for Majors).docx Coding Standards .

How to Run the Program:

  • Use g++ TwinPrime.cpp -o TwinPrime.exe and then TwinPrime.exe in a Linux terminal to compile and run.

About

This program prints every pair of prime numbers that are two apart up to the number inputted by the user.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages