Question: Write a program that will ask the user for two integers, and output the summation of all integers between including them except prime numbers.

Write a program that will ask the user for two integers, and  

Write a program that will ask the user for two integers, and output the summation of all integers between including them except prime numbers. A prime number is a whole number greater than 1 whose only factors are 1 and itself. You can have two functions: one is isPrime() to check whether the number is prime or not, and the other (sumOfRange) calculate the summation. The sumOfRange function should only calculate the sum. It should not print anything! In main, print the numbers and the summation. Example of the output is as follow: Enter first number: 2 Enter second number: 10 Sum of integers from 2 to 10(except primes) = 37

Step by Step Solution

3.35 Rating (158 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!