Print all the pairs of prime numbers which is equal to the sum of the given no. entered by user.

First you have to learn how to generate the list of prime numbers. There are lots of examples here, just search for them. Use the "Site Search" button located in the upper-right corner of the DaniWeb yelllow (gold?) band.

yes i already know how to print prime numbers help me in getting pair of prime nos. which is equal to the sum of given number .
i m getting difficulty in that

brute force.

Once you have your list of prime numbers:

For each prime number less than the user defined number, add it to each of the other prime numbers in your list. If the result of that comparison is equal to the user defined number, keep that pair.


Seems pretty simple, is that what you were looking for?

Also, if I understand you correctly, I think a better way to phrase your question would be:


Find all pairs of prime numbers, the sum of which equals a user defined value.

No?

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.