Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

use language c to Write a function that calculates the sum of all prime numbers between 1 and an input integer ( inclusive ) .

use language c to Write a function that calculates the sum of all prime numbers between 1 and an input integer
(inclusive). The input integer should be greater than or equal to 1. The two function parameters are the input
integer and a pointer indicating the location to which the result should the written. The function should return 0
in case of successful execution or return -1 in case of malformed/bad input.
int primesum(int n, int *sum); //function prototype
Example: If n=11, then your function should calculate 2+3+5+7+11=28, since these are the prime numbers
between 1 and 11. Your function should then write the answer (28) to the memory location pointed to by the
pointer sum.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions

Question

=+1. What is the brand's character or personality?

Answered: 1 week ago

Question

Why are flexible resources essential to lean production?

Answered: 1 week ago