How would I transform the following program to allow the user to input an odd number of positive integers in a single line (space-separated). In other words, how would I change the array to allow user...


How would I transform the following program to allow the user to
input
an odd number of positive integers in a single line (space-separated). In other words, how would I change the array to allow user input? The program should output the number that occurs the odd number of times.




Code to be Modified:


#include


using namespace std;



int getNumOccurredOdd(int arr[], int n)  {


   int res = 0;


   for (int i = 0; i < n;="">


      res = res ^ arr[i];


   return res;


}


int main() {


   int arr[] = {3, 4, 6, 5, 6, 3, 5, 4, 6, 3, 5, 5, 3};


   int n = sizeof(arr)/sizeof(arr[0]);


   cout < getnumoccurredodd(arr,="" n)="">< "="" is="" present="" odd="" number="" of="">


}



Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here