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

C++ Use the CLASS I PROVIDED!!!! REVISE THIS CLASS BELOW (LINK PROVIDED): 1. Ove

ID: 3872475 • Letter: C

Question

C++

Use the CLASS I PROVIDED!!!!

REVISE THIS CLASS BELOW (LINK PROVIDED):

1. Overload increment (pre & post) operator(++ )for the CLASS I PROVIDED

If f1 is a Fraction object holding the values 2/5 then: cout << ++f1; will display 3/6

and cout << f1++; after, then the output will still be 3/6 but internally f1 will have value of 4/7

Here's my int main ()

int main ()

{

Fraction f1;

Fraction f2(3);

Fraction f3(4,5);

cout<

f1.print();

f1.setFraction(2, 9);

cout <<"Fraction is: "<

f1.print();

cout << " ";

return 0;

}

2. Implement a function IN THE CLASS I PROVIDED to sort an array using either the Selection sort, Bubble sort or Insertion soft.

Explanation / Answer

ANSWER::

#include <iostream>

using namespace std;

void SelectionSort (int arr[], int n)

{

int i, j;

for (i = 0; i < n; ++i)

{

for (j = i+1; j < n; ++j)

{

if (arr[i] > arr[j])

{

arr[i] = arr[i]+arr[j];

arr[j] = arr[i]-arr[j];

arr[i] = arr[i]-arr[j];

}

}

}

}

int main()

{

int n, i;

cout<<" Enter the number of data element to be sorted: ";

cin>>n;

int arr[n];

for(i = 0; i < n; i++)

{

cout<<"Enter element "<<i+1<<": ";

cin>>arr[i];

}

SelectionSort(arr, n);

cout<<" Sorted Data ";

for (i = 0; i < n; i++)

cout<<"->"<<arr[i];

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote