C# 1. Create an application that prompts the user to enter a number between 0 an
ID: 3712989 • Letter: C
Question
C#
1. Create an application that prompts the user to enter a number between 0 and 100 in an iteration until the user has
entered a number that’s not within a valid range. After the user has entered all the numbers, display the number
that the user has entered the most as well as the number of times the user has entered that number.
2. Given an array of integers, identify the largest EVEN number and the smallest ODD number. The method will return
a decimal value that is the largest EVEN number divided by the smallest ODD number. If there are no such
numbers, the method will return a zero instead. For example, if the array is {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, the method
will return a 9 (because 9/1 is 9).
3. Given an array of integers, return the reverse of that array. For example, if the array is {1, 2, 3, 7, 8, 9}, the method
will return {9, 8, 7, 3, 2, 1}.
Explanation / Answer
Question 2:
# include <iostream>
using namespace std;
int main()
{
int num, meven=0, modd=1;
cout<<"ENTER NUMBER (0 TO TERMINATE): ";
do
{
cin>>num;
if(num%2==0)
{
if(num>meven)
meven=num;
}
else
{
if(num>modd)
modd=num;
}
}while(num);
cout<<"LARGEST EVEN NUMBER IS:"<<meven<<endl;
cout<<"LARGEST ODD NUMBER IS:"<<modd<<endl;
if(meven == 0 || modd == 1){
return 0;
};
else {
return meven/modd;
};
};
Question 3:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.