Enter an integer for option . ENTERI 1 How many integers 3 Enter integer r 1004
ID: 3881161 • Letter: E
Question
Enter an integer for option . ENTERI 1 How many integers 3 Enter integer r 1004 Enter integer 3: 88645 The original arrays Calling getlargestintegerwithLargesETUEDC After the function completed and returned the value the areest integer that has the largest unique ENEN digit count is MENU - HI. "1 1. Calling getLargestIntegerWithLargestTUEDC) 2. Quit Enter an integer for option ENTER 1 How many integers? 4 Enter integer #1: 1004 Enter integer #2: -2111 Enter integer #3 : 602400 Enter integer #4 : 80645 The original array: 1004 602486 80645 Calling getLargestIntegerWithLargestTUEDc) After the function completed and returned the value, the largest integer that has the largest unique ENEN digit count is 602400 MENU - HW #1 * 1. Calling getLargestIntegerWithLargestTUEDC)* *2. Quit Enter an integer for optionENTER: 1Explanation / Answer
#include<iostream>
using namespace std;
void displayClassInfoYourName()
{
//printing data
cout<<"CIS 25 - C++ Programming ";
cout<<"Laney College ";
cout<<"YourName ";//replace your name here
cout<<"Assignment Information -- ";
cout<<" Assignment Number: Homerwork 1, ";
cout<<" Coding Assignment -- Exercise #1 ";
cout<<" written by: YourName ";//change your name
cout<<" Submitted Date: Due Date ";
}
int getLargestIntergerwithLargestTUEDC(int a[],int n)
{
int c=0,r=0,k;
int i=0,b[n];
for(i=0;i<n;i++)b[i]=0;
i=0;
while(i<n)
{
c=a[i];
while(c>0)//counting number of even digits in each integer
{
r=c%10;
if(r%2==0)
b[i]++;
c=c/10;
}
i++;
}
i=0;
int max=0;
while(i<n)//finding value with max even digits
{
if(b[i]>b[max])max=i;
i++;
}
if(b[max]!=0)return a[max];
return -9999;//if no such digit exist...
}
int main()
{
displayClassInfoYourName();
int c;
while(1)
{
//printing menu
cout<<" **************************************************** ";
cout<<"* MENU - HW #1 * ";
cout<<"* 1. Calling getLargestIntergerwithLargestTUEDC() * ";
cout<<"* 2. Quit * ";
cout<<"**************************************************** ";
cout<<"Enter an integer for option + ENTER:";
cin>>c;
if(c==1)
{
int n;
//reading input/...
cout<<"How many integers? ";
cin>>n;
int a[n];
int i;
for(i=0;i<n;i++)//reading n integer
{
cout<<"Enter integer #"<<(i+1)<<": ";
cin>>a[i];
}
//printing array
cout<<"The Original Array: ";
for(i=0;i<n;i++)
{
cout<<" "<<a[i]<<endl;
}
//function calling
cout<<"Calling getLargestIntergerwithLargestTUEDC() ";
int d = getLargestIntergerwithLargestTUEDC(a,n);
//printingg output
cout<<"After the function completed and returned the value, the ";
cout<<"largest integer that has the largest unique ENEN digit count is ";
cout<<d<<endl;
}
else if(c==2)
{
break;//stoping process
}
else
{
cout<<"Wrong Option! ";
}
}
return 0;
}
output:
CIS 25 - C++ Programming
Laney College
YourName
Assignment Information --
Assignment Number: Homerwork 1,
Coding Assignment -- Exercise #1
written by: YourName
Submitted Date: Due Date
****************************************************
* MENU - HW #1 *
* 1. Calling getLargestIntergerwithLargestTUEDC() *
* 2. Quit *
****************************************************
Enter an integer for option + ENTER:4
Wrong Option!
****************************************************
* MENU - HW #1 *
* 1. Calling getLargestIntergerwithLargestTUEDC() *
* 2. Quit *
****************************************************
Enter an integer for option + ENTER:1
How many integers? 4
Enter integer #1: 1004
Enter integer #2: -2111
Enter integer #3: 602400
Enter integer #4: 80645
The Original Array:
1004
-2111
602400
80645
Calling getLargestIntergerwithLargestTUEDC()
After the function completed and returned the value, the
largest integer that has the largest unique ENEN digit count is
602400
****************************************************
* MENU - HW #1 *
* 1. Calling getLargestIntergerwithLargestTUEDC() *
* 2. Quit *
****************************************************
Enter an integer for option + ENTER:2
Process exited normally.
Press any key to continue . . .
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.