Question: Is this program correct for C++?explain the difference between print, voidprint,cout and cin /*Create a Program that complies with the following: a) Ask for two

Is this program correct for C++?explain the difference between print, voidprint,cout and cin
/*Create a Program that complies with the following:
a) Ask for two numbers
b) Determine the range between these two numbers
c) Show the prime numbers within the range
d) Show the sum of the even and odd numbers within the range * /
#include
#include
using namespace std;
int odd(int min, int max)
{int c, s = 0;
for (c = min; c <= max; c++) {
if (c % 2 == 1) {
s += c;}}
return s;}
int even(int min, int max)
{int c, s = 0;
for (c = min; c <= max; c++) {
if (c % 2 == 0) {
s += c;}
}return s;}
int primo(int n)
{for (int c = 2; c < n; c++) {
if (n % 2 == 0) {return 0;
}}
return 1;}
void printprimo(int min, int max)
{
cout << " Los numeros primos son : ";
for (int c = min; c <= max; c++) {
if (primo(c) == 1) {
cout << c ;
}}
cout <<" ";}
void print(int min, int max){
cout << " El rango de los numeros es: ";
for (int c = min; c <= max; c++) {
cout << c;}
cout <<" ";}
int main(){
int min, max;
cout << " Ingrese el numero minimo: ";
cin >> min;
cout << " Ingrese el numero mayor: ";
cin >> max;
print(min, max);
cout << " La suma de los numeros pares es: " << even(min, max) << endl;
cout << " La suma de los numeros impares es: " << odd(min, max) << endl;
printprimo(min, max);
system("pause");
return 0;}

Step by Step Solution

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 Databases Questions!