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
operating systems for mobile devices can support full-scale software programs like Microsoft Word or Excel
goldfiish [28.3K]
Mobile devices are unable to run full scale software programs like MS Word or Excel. They can run apps however with smaller capabilities as they require less hardware and specifications than the full version
The answer is false
7 0
3 years ago
A user needs to open some files that are being shared from a remote computer. however, the user receives an "access denied" mess
scoundrel [369]
Hes not a member of the group that has been granted access to view the files
5 0
4 years ago
Using logical operators, 1 AND 0 =
g100num [7]
O. In an AND gate both values need to be 1 to equal 1.
4 0
3 years ago
Delete name range in excel
Flura [38]

Answer:

Further explanation?

Explanation:

5 0
3 years ago
Part 2: students and courses, part 1  java review you may use an ide or a text editor, but i will test this by compiling and ru
aivan3 [116]
You need to plug turn in office equipment 
7 0
4 years ago
Other questions:
  • Give a big-O estimate for the number additions used in this segment of an algorithm.
    7·1 answer
  • What are the pros and cons of the internet’s ability to access information
    8·2 answers
  • In Online Data Extraction data is extracteddirectly from the ------ system itself.o Hosto Destinationo Sourceo Terminal
    15·1 answer
  • Name two ways you can identify the pid number of the login shell.
    13·1 answer
  • 2min speech on can teachers be replace by technology​
    5·1 answer
  • Find the area of square whose perimeter is 260.8m​
    12·1 answer
  • 8. What is the correct jQuery code to set the background color of all p elements to red?
    15·1 answer
  • What is 36 Denary in Binary?? PLEASE ANSWER I WILL GIVE U BRAINLY!!
    9·2 answers
  • ANSWER ASAP GIVING BRAINIEST FIVE STAR AND HEART!
    5·2 answers
  • Henry wants to create a presentation for his clients. He wants to upload the presentation file directly to the Internet. Which p
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!