Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

IN c++ 1- (5pts) Write a program that asks the user to enter 3 real numbers betw

ID: 3568498 • Letter: I

Question

IN c++

1- (5pts) Write a program that asks the user to enter 3 real numbers between -100 and 100 then displays
the following menu:
a- Display the maximum
b- Display the minimum
c- Display the numbers sorted in decreasing order
d- Display odd numbers
e- Display even numbers
f- Write the numbers in a file.
g- Exit.
Very Important:
1- The user has to enter the numbers only one time at the beginning of the execution of the
program.
2- The numbers need to be validated by the program to be between -100 and 100
3- The program will have to repeatedly asks the user to enter his choice and executes the
required task until the user enters g to stop the execution of the program.
4- If the user enters option

Explanation / Answer

#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
const int size=3;
// array with size of 10
int array[size];
for (int count = 0; count < size; count ++)
{
       cout << "Please enter 3 numbers: ";
       cin >> array[3];              
   }
  
// initializing max, min
int max=array[0];
int min=array[0];
/* scanning array to find
minimum and maximum
number */
for(int i=0;i<size;i++){
// finding minimum number in array
if(min>array[i]){
min=array[i];
}
//finding maximum number in array
if(max<array[i]){
max=array[i];
}
}

//sorting
cout<<"after sorting";
for(int x=0;x<size;x++){
for(int z=0;z<size;z++){
int v = z;
if(array[z] < array[z+1]){
v = array[z];
array[z] = array[z+1];
array[z+1] = v;
}
}
}
// displaying output
cout<<"Maximum Number is :"<<max<<endl;
cout<<"Minimum Number is:"<<min<<endl;
for(int i=0;i<size;i++){
// Displaying array value
cout<<array[i]<<endl;
}
  
//calcualate Even or Odd
for(int i=0;i<size;i++){
if(array[i]%2==0){
cout<<"This number is even number:"<<array[i];
cout<<" ";
}
else
{
cout<<"This number is Odd number:"<<array[i];
cout<<" ";
}
}

return 0;
}