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

Sc47pro/ector = 1 Assigneent Information Assignment Number: Homework 82, Coding

ID: 3870552 • Letter: S

Question

Sc47pro/ector = 1 Assigneent Information Assignment Number: Homework 82, Coding Assignment -- Exercise #1 Your Name Written by: Submitted Date: Due Date 99940990899 MENU-HW #2 . 1. Calling extractuncommonDigitYourName() * 2. Quit Select an option (1 or 2): 4 WRONG OPTION! MENU HW 2 1. Calling extractuncommonDigitYourName) *2. Quitl Select an option (1 or 2): 1 How many integers? 3 Enter integer #1: 3256615 Enter integer #2: -2375761 Enter integer #3: 3828563 The original array: 3256615 -2375761 3828563 calling extractuncommonDigitYourName) Displaying after returning the array The Uncommon Digits There is/are 3 uncommon digit(s) with 2 even uncommon digit(s) of below And 1 odd uncommon digit(s) of below (7, 2) MENU -HW #2 1. Calling extractUncommonDigitYourName) oe@ :

Explanation / Answer

#include <iostream>
#include <math.h>

using namespace std;
void uncommondigityourname();
int main() {
int option=0;
while(true){
cout << "1. Calling UncommonDigitYourName" <<endl;
cout << "2. Quit" <<endl;
cout << "Select an option ( 1 or 2)" <<endl;
cin >> option;
if(option==2)break;
if(option==1)uncommondigityourname();
}
}

void uncommondigityourname(){
int n;
cout <<"How many integers?";
cin>>n;
int * arr = new int[n];
int digits[10]={0,0,0,0,0,0,0,0,0,0}; // How many times each digit occurs in the numbers
for(int i=0;i<n;i++){
cout<<"Enter integer #" << i << ": ";
cin>>arr[i];
int number=abs(arr[i]);
while(number>0){
int digit = number % 10;
digits[digit]++;
number=number/10;
}
}
int min=32767;
for(int i=0;i<10;i++){
cout<<digits[i]<<" " <<endl;
if(digits[i]==0)continue;
if(digits[i]<min)min=digits[i];
  
}
//cout<<min<<endl;
cout<<"Even uncommon digits"<<endl;

for(int i=0;i<10;i++){
if(digits[i]==min){
if(i%2==0){
cout<<"{"<<i<<","<<digits[i]<<"}"<<endl;
}
}
}
cout<<"Odd uncommon digits"<<endl;
for(int i=0;i<10;i++){
if(digits[i]==min){
if(i%2!=0){
cout<<"{"<<i<<","<<digits[i]<<"}"<<endl;
}

}
}
}