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
Series-connected 11-pF and 21-pF capacitors are placed in parallel with series-connected 22- pF and 30-pF capacitors. Determine
Naya [18.7K]

Answer:

19.9 pF

Explanation:

Given that:

Series connection :

11pF and 21pF

C1 = 11pF ; C2 = 21pF

Cseries = (C1*C2)/ C1 + C2

Cseries = (11 * 21) / (11 + 21)

Cseries = 7.21875 pF

C1 = 22pF ; C2 = 30pF

Cseries = (C1*C2)/ C1 + C2

Cseries = (22 * 30) / (22 + 30)

Cseries = 12.6923 pF

Equivalent capacitance is in parallel, thus,

7.21875pF + 12.6923 pF = 19.91105 pF

= 19.9 pF

8 0
3 years ago
Your mother is sure that you were driving too fast because she knows
Klio2033 [76]

I think the corret answer would be C

5 0
3 years ago
Read 2 more answers
De dónde proviene la mayoría de cosas que utilizamos en el hogar​
Mashutka [201]

Answer:

La mayoría de las cosas que utilizamos en el hogar proviene de distintas industrias ubicadas a lo largo y ancho del mundo, dado que vivimos en un mundo globalizado e industrializado, en el que las distintas naciones intercambian bienes y servicios a través del comercio internacional.

De esta manera, en los distintos hogares hay cosas de diversos orígenes, como electrodomésticos provenientes de China, Japón o los Estados Unidos, muebles provenientes de México o Suecia, alimentos provenientes de Argentina, etc.

7 0
2 years ago
A​ _______ variable is a variable that has a single numerical​ value, determined by​ chance, for each outcome of a procedure.
7nadin3 [17]
Single variable is the answer
5 0
3 years ago
The following code has which kind of error?
Mila [183]

Answer:

There would be a logic error.

Explanation:

The count for x should have been initialized before addint it to the variable total.

6 0
2 years ago
Other questions:
  • If you define CSS rules on a parent control, the rules will be inherited by all of the children widgets.
    12·1 answer
  • When was the GoPro camera invented?​
    6·1 answer
  • Which certification can help enhance your job prospects in the role of a computer programmer?
    10·2 answers
  • def getCharacterForward(char, key): """ Given a character char, and an integer key, the function shifts char forward `key` steps
    9·1 answer
  • Assume the following variable definition appears in a program:
    8·1 answer
  • What is the "online disinhibition effect"?​
    7·1 answer
  • You can invoke or call a method from another program or method. When methods must share data, you can pass the data into and ret
    6·1 answer
  • Which line of code will only allow a symbol to be stored in a variable?
    11·2 answers
  • Why might reading a product review be a good idea before purchasing a product?
    5·2 answers
  • What happened to the ten commandments tablets.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!