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
Two technicians are discussing engine valve timing. Technician A says that the optimum valve timing is found through experimenta
nordsb [41]
The answer is B. A only. The optimum valve timing is found through experimentation using an engine dynamometer. The timing of the opening and closing of the valves is called valve timing. So the use of dynamometer measures the power output of a machine that is why it can measure the optimum valve timing.
7 0
3 years ago
Read 2 more answers
The top-level domain name of .com indicates that the website is
Ira Lisetskai [31]
C. commercial

is ur answer
5 0
3 years ago
Read 2 more answers
The incident response team reviewed the security logs and discovered that the network had been breached, due to a misconfigured
natka813 [3]

Answer:

This is a failure of prevention model of computer security

Explanation:

Because the firewall was misconfigured so attack prevention mechanism failed to resist the attack and the security of computer is compromised. Prevention is an important model of operational security because <em>protection </em>is possible firstly attacks are prevented from targets and if not prevented and failed then they are detected and finally security department respond to that attack.

protection = <em>prevention   </em>if <em>prevention </em>failed than (detection+response)

4 0
3 years ago
PLZZZZZZZZ HURRY What is FireWire?
ycow [4]

Answer:C

Explanation:

7 0
3 years ago
Read 2 more answers
You right-click a Server Core server in Server Manager and click Computer Management. You see an error indicating that the serve
Anarel [89]

Answer:

Configure Windows Firewall on the remote computer.

Explanation:

3 0
3 years ago
Other questions:
  • Write a Raptor program that will generate a random number between 1 and 100; do not display the randomly generated number. Let t
    8·2 answers
  • When you make a pointer variable im C++, is star label a must?
    9·1 answer
  • What were precomputed tables and why were they necessary?​
    12·2 answers
  • what aspect should you consider before adding pictures to a document? you should structure the first before you search for a rel
    15·2 answers
  • What property do we use to distinguish a specific element from a form? value name click this
    12·1 answer
  • Complete the program segment below to write the numbers 1 through 50 to the numbers.txt file.
    5·1 answer
  • Design and implement an algorithm that gets a list of k integar values N1, N2,...Nk as well as a special value SUM. Your algorit
    10·1 answer
  • In most programming languages, the compiler carries a preprocessing step to determine if certain statements will compile. For in
    7·1 answer
  • What are the features of a computer speaker​
    10·1 answer
  • A(n) ________ will clear all user data and setting changes, returning the device's software to the state it was in when it left
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!