Write a C++ program which reads a given integer n and prints its twin
prime.
"A twin prime is a prime number 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 of two".
Sample Output:
Enter an integer:
11
Twin prime number of 11 is:
13

Answers

Answer 1

The C++ program that reads a given integer n and prints its twin prime is given below:

The Program

#include <iostream>

#include <cmath>

using namespace std;

int main() {

   const int num_primes = 10005;

   bool primes[num_primes];

   for (int i = 2; i != num_primes; ++i) {

       primes[i] = true;

   }

   for (int i = 2; i != int(sqrt(num_primes)); ++i) {

       if (primes[i]) {        

           for (int j = 2; i * j < num_primes; ++j) {

               primes[i*j] = false;

           }

       }

   }

   int n;

cout << "Input an integer:\n";

   cin >> n;

cout << "Twin primes are:\n";

       for (int i = n; i - 2 >= 0; --i) {

           if (primes[i] && primes[i-2]) {

               cout << i-2 << " " << i << endl;

               break;

           }

   }

   return 0;

}

The Output

Input an integer:

Twin primes are:

11 13

Read more about programming here:

https://brainly.com/question/23275071

#SPJ1


Related Questions

Describe the differences between power and authority

Answers

Answer:

power is authjority

Explanation:

Which of the following protects intellectual property?
A. copyright
B. trademark
C. putting on a play
D. writing a novel

Answers

Answer:

A). Copyright

the next questions answer is

C). For the life of the author plus seventy years.

Explanation:

I just did the Assignment on EDGE2022 and it's 200% correct!

Also, heart and rate if you found this answer helpful!! :) (P.S It makes me feel good to know I helped someone today!!)

(7) Accept a 4-digit number from a user. Your task is to create a simple encrypted corresponding value
of this number. First separate each number into its individual digits. For each individual digit, if the
individual digit is greater than or equal to 5, subtract that value from 9. Output the new value (in its
individual digits) which would now represent the encrypted corresponding value. For example, if the
user entered 5678, the encrypted corresponding value would be 4 2 3 1. (Required: IPO chart,
Pseudocode, C-program and Python)

Answers

Using the knowledge in computational language in python it is possible to write a code that create a simple encrypted corresponding value

of this number.

Writting in the C code:

#include<stdio.h>

int main()

{

   int num,r,rev=0;

   scanf("%d",&num);

   while(num!=0)

   {

       r=num%10;

       rev=rev*10+r;

       num=num/10;

   }

   while(rev!=0)

   {

       r=rev%10;

       if(r>=5)

       {

           r=9-r;

       }

       printf("%d ",r);

       rev=rev/10;

   }

   return 0;

}

Writting in python code:

num=int(input("Enter number:"))

rev=int(str(num)[::-1])

while rev!=0:

   r=rev%10

   if r>=5:

       r=9-r

   print(r,end=" ")

   rev=rev//10

See more about python at brainly.com/question/12975450

#SPJ1

Classify the following devices as input or ourput. Draw a line from the picture to the correct name of the device.​

Answers

Answer:

input: keyboard + mouse

output: monitor + printer

A designer wants to design for the smallest and most basic version of their site, like for a mobile phone. What approach should they use? (UX)


Dedicated desktop web design

Graceful degradation

Progressive enhancement

Dedicated mobile app design

Answers

Answer:

Progressive enhancement

OR

Dedicated mobile app design

Most likely Dedicated mobile app design

What is the memory size, in bytes, of a float? (Note: 1byte = 8bits)

Answers

Answer: 4 bytes

Explanation: if doubled be 8 bytes

1. How are you going to apply proper selection of tools in your daily life?

2. Do you think knowing each tool used for computer systems servicing will be a big help for you in the future?

3. How important for a student like you to know the scope of work you should properly accomplish?​

Answers

Answer:

PROPER TOOLS SELECTION 2. Tool •Is a handheld device that aids in accomplishing a task •Range from a traditional metal cutting part of a machine to an element of a computer program that activates and controls a particular function. 3. Preparing for the task to be

Explanation:

What can a programmer expect when writing a modular program for a game

Answers

Answer:

That it's gonna be hard.

Marc is a gamer and is in the market for a new computer to support a lot of graphics. He needs to find a computer with a high amount of RAM, because the higher the RAM, the faster it will function.

A: True
B: False

Answers

Since Marc is a gamer and is in the market for a new computer to support a lot of graphics. He needs to find a computer with a high amount of RAM, because the higher the RAM, the faster it will function is option A: true statement.

What is the statement of the higher the RAM, the faster it will function about?

In regards to computing, when the RAM is known to be faster, one can say also that  the faster will be the computer  the processing speed.

Note that when there is a faster RAM, a person or a computer user can be able to increase the speed through which the computer memory moves information to other parts of the system.

This implies that  there is a fast processor and thus an equally faster means of talking to the other areas of the system, making the computer to be much more good.

Therefore, Since Marc is a gamer and is in the market for a new computer to support a lot of graphics. He needs to find a computer with a high amount of RAM, because the higher the RAM, the faster it will function is option A: true statement.

Learn more about RAM from

https://brainly.com/question/13196228

#SPJ1

MC Qu. 05 The most common way to access the Internet i...
The most common way to access the Internet is through

Answers

Answer: The most common way to access the internet is through Mobile phone

To tell an audience a story about a data set, it is best to use a _____________.

A) memo
B) graph
C) dashboard
D) report

Answers

Your answer should be (B
it is best to use a graph.

a prospect calls a sales rep at a firm as teh prospect listend to her pitch he keeps pushing back that the price is higher than most. What should the rep do?

Answers

Since there is a prospect calls a sales rep at a firm as the prospect listened to her pitch he keeps pushing back that the price is higher than most. the thing that the rep can do is option d: Ask him to set aside price for now to see if the services are a good fit.

How to be a sales rep

A sales rep is known to be any body that is a person who is said to function as the seller of products or services for a given firm.

Note that they are often in seen in a specific field or area. Rep is a wood that is the short form for representative. The term sales representative are people who often works for (stand) for a company but the salesperson is one that can also be selling their own special products.

There are different kinds of calls and there are ways to handle such calls. Based on the scenario above, Since there is a prospect calls a sales rep at a firm as the prospect listened to her pitch he keeps pushing back that the price is higher than most. the thing that the rep can do is option d: Ask him to set aside price for now to see if the services are a good fit.

Learn more about sales rep  from

https://brainly.com/question/28410390

#SPJ1

A prospect calls a sales rep at a consulting firm. As the prospect listens to her sales pitch, he keeps pushing back that the price is higher than most. What should the rep do? a. Agree that her company's services are expensive but promise that they'll solve his problems b. Ask him to hold and check with her supervisor if she can offer a discount a c. Ask him what price he would consider fair and reasonable d. Ask him to set aside price for now to see if the services are a good fit e. Point out that if he did his research, he knows that her company's services are better than those of competitors

What are Thear Platforms?

Answers

A computing platform or digital platform is an environment in which a piece of software is executed. It may be the hardware or the operating system, even a web browser and associated application programming interfaces, or other underlying software, as long as the program code is executed with it.

Answer:

A conglomerate technology company.

Explanation:

Thear Platforms is commonly known as Thear. It is a conglomerate technology company with different platforms.

Some platforms by Thear are as follows

1. Thear Blog (Blogging Site)

2. Thear Library (Educational Site)

3. Thear Updates (News Site)

and many others....

You may access these at https://thear.me/

which Preview in Lightroom allows you to edit images that are not physically connected to your computer

Answers

The Preview in Lightroom allows you to edit images that are not physically connected to your computer is Smart Preview.

What is Lightroom?

Lightroom assists you with importing, organizing, managing, and finding photographs. Lightroom, on the other hand, combines picture management and photo editing into a single product. Lightroom is a non-destructive picture editor.

Lightroom Classic's Smart Previews feature allows you to edit photographs that are not physically linked to your computer. Based on the lossy DNG file format, Smart Preview files are a lightweight, smaller file format.

Hence, the Preview in Lightroom allows you to edit images that are not physically connected to your computer is Smart Preview.

Learn more about LightRoom here:

https://brainly.com/question/14509650

#SPJ1

Besides UEFI, what other type of firmware might you see on a motherboard?

Answers

Besides UEFI, the other type of firmware that you might see on a motherboard is BIOS.

What is a computer hardware?

A computer hardware can be defined as a physical component of an information technology (IT) or computer system that can be seen and touched.

The hardware components of a computer.

Some examples of the hardware components of a computer system and these include:

MonitorMouseRandom access memory (RAM).Read only memory (ROM).Central processing unit (CPU)KeyboardMotherboard BIOS chip

In Computer technology, the two types of of firmware that you might see on a motherboard are Basic Output-Input system (BIOS) and Unified Extensible Firmware Interface (UEFI).

Read more on motherboard BIOS chip here: brainly.com/question/17373331

#SPJ1

8. What should one do in order to gain the most benefit from the concept of learning styles?
a. Be rigid
b. Be persistent
c. Be imaginative
d. Stay flexible

D stay flexible

Answers

The thing that a person should do in order to gain the most benefit from the concept of learning styles is option D: stay flexible.

What does learning styles mean?

Learning styles can be categorized, identified, and described in a variety of ways. They are, in general, broad patterns that give teaching and learning direction.

Another way to think of learning style is as a set or a given group of elements, actions, as well as attitudes that support a person's learning in a specific circumstance.

Therefore, based on the above, The thing that a person should do in order to gain the most benefit from the concept of learning styles is option D: stay flexible.

Learn more about learning styles from

https://brainly.com/question/3274282
#SPJ1

What is the relationship between the ask phase of the data analysis process and the plan phase of the data life cycle?

Answers

Answer:

The data analytic lifecycle is intended for use with data science initiatives and Big Data issues. The cycle reflects a real project by being iterative.

Where do you search to identify the user who last modified a shared document in Word 2019?
O in the Data tab
O in the Help view
O in the Review tab
O in the Backstage view

Answers

The option where  you search to identify the user who last modified a shared document in Word 2019 is option c: in the Review tab.

How can you tell when a Word document was last modified?

In Word, a person can be able to the document properties if only they click the File tab and then select Info to display the properties for an open document in Word.

Note that the document's properties are listed on the right side of the window, including the Last Modified date, the creation date, and others.

Hence,  the Review Tab's functions include document proofreading and giving you the option to get input on your final revisions.

Therefore, based on the above, The option where  you search to identify the user who last modified a shared document in Word 2019 is option c: in the Review tab.

Learn more about Word document from

https://brainly.com/question/1596648
#SPJ1

Answer: Its The Backstage view..  right on EDGE

Explanation:

Help please‍♀️

What is the name for the different RULES that are specific to each programming
language? These languages use commands and logic statements to make the
computer accomplish its intended purpose.

Software

Programs

Syntax

Binary

Answers

Answer:

syntax

Explanation:

Each programming language follows a specific set of “grammar” rules called syntax; Every programming language is designed to serve a specific purpose, i.e. to allow you to build websites, do data analysis, or create desktop software etc.

Im in 7th grade :D

Is Qatar a highly restricted internet censored country? What is the best free VPN for Qatar?

Answers

Answer: Yes.

Explanation:

Qatar is a highly restricted country in terms of the internet freedom. It keeps blocking different websites that may go against its culture. In

Qatar is a highly restricted country in terms of the internet freedom. It keeps blocking different websites that may go against its culture.

You may look for the best free security tool for Qatar. But, it will not work best. You must try the paid, best security tool for Qatar that is reliable and highly secured. CovermeVPN the best security tool for Qatar.

Amed is utilizing a feature that will use two tables. The first table contains a primary key matched to a foreign key in the second table. The query results will include all entries from the first table. Which feature is he using?

left outer join
right outer join
self join
inner join

Answers

Answer:

left outer join

Explanation:

HELP ME OUT PLEASE!!!!!!!

________ this design element is used to indicate hierarchy.

A) Line
B) Decorative
C) Shade
D) Balance​

Answers

Answer:

Line

Explanation:

Because they have a big line thanks for the points please help me with my problem is in my profile

Answer:

Line

Explanation: Because they have a big line thanks for the points please help me with my problem is in my profile

Wendy Patel is entering college and plans to take the necessary classes to obtain a degree in architecture. Research the programs and apps that Wendy might use in her degree program and recommend a computer with sufficient hardware specifications to adequately support her through the degree program. Provide a link to the computer you locate and justify why you feel the computer will best meet her needs. Why did you choose the central processing unit? Why did you choose the amount of RAM? Why did you choose the storage device?

Answers

Some of the programs and apps that Wendy might use in her degree program of architecture are:

AutoCAD Mobile AppMorpholio Trace Pro.ARki. ArchiSnapper 5.MagicPlan.Shapr3D

A recommended computer that Wendy Patel can use in her university study of obtaining a degree in architecture is an ASUS ZenBook S Ultra Slim Flip Laptop.

The RAM is 16GB RAM and the CPU is an 11th Generation Core i7-1165G7 chip that would help her navigate through her design projects.

What is Architecture?

This refers to the process of designing and constructing buildings with the aid of software.

Hence, we can see that Some of the programs and apps that Wendy might use in her degree program of architecture are:

AutoCAD Mobile AppMorpholio Trace Pro.ARki. ArchiSnapper 5.MagicPlan.Shapr3D

A recommended computer that Wendy Patel can use in her university study of obtaining a degree in architecture is an ASUS ZenBook S Ultra Slim Flip Laptop.

The RAM is 16GB RAM and the CPU is an 11th Generation Core i7-1165G7 chip that would help her navigate through her design projects.

Read more about architecture here:

https://brainly.com/question/9760486

#SPJ1

Karen has a discrete analog clock in the shape of a circle. Two hands rotate around the center of the circle, indicating hours and minutes. The clock has 60 marks placed around its perimeter, with the distance between consecutive marks being constant.
The minute hand moves from its current mark to the next exactly once every minute. The hour hand moves from its current mark to the next exactly once every 12 minutes, so it advances five marks each hour. We consider that both hands move discretely and instantly, which means they are always positioned exactly over one of the marks and never in between marks.
At midnight both hands reach simultaneously the top mark, which indicates Zero hours Zero minutes. After exactly 12 hours or 720 minutes, both hands reach the same position again, and this process is repeated over and over again. Note that when the minute hand moves, the hour hand may not move; however, when the hour hand moves, the minute hand also moves.
Karen likes geometry, and she likes to measure the minimum angle between the two hands of the clock at different times of the day. She has been writing some measures down, she noticed that some angles were repeated while some others never appeared. For instance, Karen noticed that both at three o'clock and at nine o'clock the minimum angle between the two ands is 90 degrees, while an angle of 65 degrees not appear in the list.
Karen decided to verify, for any integer number between 0 and 180, if there exists at least one time of the day such that the minimum angle between the two hands of the clock is exactly A degrees. In this lab you will code a program to help Karen to answer this question and display which hour meet the angle.
NOTE: Your program needs to perform operation(s) and use control statements to solve the problem. Solutions that imply to create a switch-case or if-else for all 181 (or 91) possible values (Hard Coding) automatically will be scored with 0.
Input:
The program gets as input an integer value A s.t. (0<= A <= 180), which represents the angle to be verified. Validate that this input is within the valid range.
Output:
If there exist at least one time of the day such that the minimum angle between the two hands of the clock is exactly A degrees, then display how many hours met the specified angle and those hours in ascending order (24-hour military time clock). Otherwise display "There is no hour where the hands are A degrees apart".

Answers

Answer:

no idea

Explanation:

but I want you to know, you are a great person

why is this happening and how do I fix it?

Answers

Answer:

who is known as prophet of the computer?why?

Difference between us 2.0
and 3.0 flash drive

Answers

USB 2.0 offers a transfer rate of about 480 Mbps, whereas USB 3.0 offers a transfer rate of about 4,800 Mbps


What statement is an example of the specific requirements of smart goal?

Answers

Answer:

Specific: I’m going to write a 60,000-word sci-fi novel.

Measurable: I will finish writing 60,000 words in 6 months.

Achievable: I will write 2,500 words per week.

Relevant: I’ve always dreamed of becoming a professional writer.

Time-bound: I will start writing tomorrow on January 1st, and finish June 30th.

Explanation:

I did this mark brainiest

Select the two correct statements about Cloud Logging.

Cloud Logging lets you define uptime checks.

Cloud Logging lets you define metrics based on your logs.

Cloud Logging requires the use of a third-party monitoring agent.

Cloud Logging requires you to store your logs in BigQuery or Cloud Storage.

Cloud Logging lets you view logs from your applications and filter and search on them.

Answers

The two correct statements about Cloud Logging include the following:

Cloud Logging lets you define metrics based on your logs.Cloud Logging lets you view logs from your applications and filter and search on them.

What is cloud computing?

Cloud computing can be defined as a type of computing that requires the use of shared computing resources over the Internet rather than the use of local servers and hard drives.

What is Cloud Logging?

Cloud Logging can be defined as a fully managed service that is designed and developed to avail end users an ability to store, search, analyze, monitor, and receive notifications on logging data and events from Cloud services providers.

In this context, we can reasonably infer and logically deduce that Cloud Logging allows an end user to define metrics based on his or her logs.

Read more on Cloud storage here: https://brainly.com/question/18709099

#SPJ1

What was the largest processor used in the 1990s?
(1 point)
O 16-bit
O 32-bit
O 64-bit
O 128-bit

Answers

Answer: 64 bit

Explanation: 128 bit not used at that time

characteristics of third generation of computer​

Answers

Answer:

1. Use of Integrated Circuits (IC) instead of transistors.

2. Use of Semi-conductor memory.

3. Small size than previous generation computers.

4. Use of magnetic storage devices.

5. Improved faster operations and more dependable output.

6. Use of mini computers.

7. Use of monitors and line printers.

Other Questions
What is the purpose of the information in the red box on this nutrition label? There is one bus driver, two coaches, and three teams, each with four dancers going to a competition. Nia writes the expression 1 + 2 + 3 4 to represent everyone that will be on the bus and solves it using the following steps:1 + 2 + 3 4= 3 + 3 4= 6 4=24A. Nia concludes that 24 people will be on the bus going to the competition. Describe the mistake Nia made when solving her expression. Then write an explanation and draw a picture to help Nia understand how to solve her expression correctly.B. How would you write this expression if n represents the number of teams?C. How would this expression be different if there were two coaches for each team? Write an expression and draw a picture to support your expression. The mathematical relationship between the total cost for a person to bowl at the local bowling alley and the number of games played is represented by y = 3.50x + 6.00Explain how you can use this linear function to find out how many games you can bowl for $34.Pls don't send links or wrong answers I WILL REPORT YOU How does Aristotle's ideas about explaining the diversity of living organisms vary from the ideas of Plato?A) He explored the levels of complexities found in living organisms.B) He believed there had been one fixed creation of organisms.C) He believed that organisms are a reflection of a divinely inspired ideal form.D) He supported the idea that some organisms could change over time. True or False: Immigrants from outside the British Isles were permanently confined to second-class status because there was no process for naturalizing foreigners as British citizens. Suppose that e and f are two events and that p(e)=0.6 and p(f|e)=0.4. what is p(e and f)? Who was an artist who used classical mythology in his paintings? his birth of venus is one of the most famous paintings of the renaissance. question 7 options: donatello masaccio sandro botticelli leonardo da vinci Kassim has a water barrel in his garden. The water barrel is full and Kassim wants to know how much water is in the barrel. The barrel is a cylinder which is 1.1m high and has a diameter of 70cm. Give your answer in cm3 to three decimal places. Use 3.14 as an approximate to [tex]\pi \pi[/tex] a researcher is studying how a bacterial infection might spread through a human body. Which model could she use to simulate how it spreads through organ systems?A. Computer ModelB. Physical ModelC. Conceptual ModelD. Mathematical Model CARD #2:A figure on acoordinate plane isdilated. Point A(3, 9)is dilated to A'(1, 3).Bobby says thedilation can berepresented by(x, y).Betty says thedilation can berepresented by(3x, 3y). Managers with a(n) ________ attitude view every foreign operation as different and hard to understand. What reason might the Greeks have had not toquestion the evidence that heavier objects fallfaster than lighter objects? Write a letter to a teacher In senool mr Raphael TELLING HIM about your Future Plans What you to tends to become. In Furture (occupation) and reason why you really want to become that I not less than 450 words 45 is what percent of 180? There are 10 numbers listed below. 13.5 12.5 10.8 9 11 10 12.5 13 10.5 12 What is the mode of these numbers? 5. what are the risks associated with electronic confirmations? how can an auditor gain confidence in the reliability of responses received electronically? Write an equation of the line satisfying the given conditions. the line passes through (25,24) and is perpendicular to y=6. Arrange the population of the seven countries from least to greatest. your answer should have the numbers in scientific notation. 1.37 x 101, 2.75 x 100, 8.56 x 101, 6.37 x 107, 1.44 x 10-3, 1.83 x 104, 6.53 x 100 In 1711, England, Ireland, Scotland, and the North American colonies ______.- were no longer bound by the terms of the Navigation Acts- declared war on France and Spain- were engaged in a trade dispute over the manufacture of woolen textiles- began sharing a common postal system As se dice level 1 paragraph completion challenge activity