1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Finger [1]
1 year ago
14

Write a program in C++ to Find the Average of the sum of prime numbers between 1 to any given number

Computers and Technology
1 answer:
mixas84 [53]1 year ago
8 0

Using the knowledge in computational language in C++ it is possible to write a code that Find the Average of the sum of prime numbers between 1 to any given number

<h3>Writting in C++ code:</h3>

<em />

<em>#include <iostream></em>

<em>using namespace std;</em>

<em>bool isPrime(int n){</em>

<em>   for(int i = 2; i < n/2; i++){</em>

<em>      if(n%i == 0){</em>

<em>         return false;</em>

<em>      }</em>

<em>   }</em>

<em>   return true;</em>

<em>}</em>

<em>int findPrimeSum(int n){</em>

<em>   int sumVal = 0;</em>

<em>   for(float i = 2; i <= n; i++){</em>

<em>      if(isPrime(i))</em>

<em>         sumVal += i;</em>

<em>   }</em>

<em>   return sumVal;</em>

<em>}</em>

<em>int main(){</em>

<em>   int n = 15;</em>

<em>   cout<<"The sum of prime number between 1 to "<<n<<" is "<<findPrimeSum(n);</em>

<em>   return 0;</em>

<em>}</em>

See more about C++ code at brainly.com/question/19705654

#SPJ1

You might be interested in
Explain the third <br> generation
meriva
Computers were computers that emerged due to the development of the integrated circuit.
8 0
3 years ago
Select all the items that determine your preference for a concert ticket. a) band that is playing b) date of the concert c) pric
vlada-n [284]
I believe the answer is A, B, and C
8 0
3 years ago
Grace Hopper led the development of ______, a programming language for business applications.
soldi70 [24.7K]

Answer: Machine independent programming language which is known as COBOL.

Explanation:

 Grace hopper born in 1906 in the New York city and she made the machine independent programming language idea popular all over the world. It prompted the advancement of COBOL, an early significant level programming language even used today.

Preceding joining the US Navy, Hopper done her  Ph. D in the mathematics subject from the Yale University and she was also a professor at the Vassar College.

8 0
3 years ago
Read 2 more answers
Write a class named Car that has the following fields: yearMode1. The yearModel field is an int that holds the car's year model.
Gekata [30.6K]
Skeh wkf ahfmroztdjdy
Dmgk
Ann Write a class named Car that has the following fields: yearMode1. The yearModel field is an int that holds the car's year model. make. The make field is a String object that holds the make of the car, such as "Ford" "Chevrolet", "Honda", etc. speed. The speed field is an int that holds the car's current speed. In addition, the class should have the following methods . Constructor. The constructor should accept the car's year model and make as ments. These values should be assigned to the object's yearModel and make fields. The constructor should also assign 0 to the speed field. Accessor. The appropriate accessor methods get the values stored in an object's yearModel, make, and speed fields. , accelerate. The accelerate method should add 5 to the speed field each time it is called _________. brake. The brake method should subtract 5 from the speed field each time it is called.
8 0
3 years ago
Read 2 more answers
As a prospective student, what is the best reason to request an interview with your college application?
weqwewe [10]

Answer: The correct answer is A. I just answered this question myself!

6 0
2 years ago
Other questions:
  • What could prevent earmuffs from providing your ears good protection from noise?
    10·1 answer
  • What is a main cause of a virus on a computer
    6·1 answer
  • You've formatted the first paragraph of a document. What button can you use to apply the formatting from the first paragraph to
    9·2 answers
  • What error, if any, is in the following code?
    11·1 answer
  • When a rectangular region is defined using an appropriate style, which value matches the specified edge of the clipping region t
    7·1 answer
  • Between Handshake protocol, change cipher suite, alert and appplication data protocols, the first one to use is:
    13·1 answer
  • Which of the following is true about scalability?
    9·1 answer
  • 1. How many questions are on the Consensus Assessment Initiative document?
    10·1 answer
  • A mesh network topology allows all computers to be directly connected. True or False
    9·1 answer
  • Large and fast disks should be used for as doing so will ensure work is done as quickly as possible?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!