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

Please i need someone to help me with the assignement below, thank you Direction

ID: 3867965 • Letter: P

Question

Please i need someone to help me with the assignement below, thank you

Directions: Perform a detailed analysis of the differences and similarities between M1 and M2 below

M1

#include <iostream>

#include <conio.h>

#include <string>

#include "M7.h"

using namespace std;

void main()

{

       string sName;

       const int iArraySize = 5;

       int iArray [iArraySize] = {0};

       float fArray[iArraySize] = {0.0};

       ProgramHeader();//function call for the program header

      

       menu(sName, iArray, fArray, iArraySize);// the menu

       system("cls");//clearing the DOS window

       Output(sName);//outputing the char array

       Output(iArray, iArraySize);//outputing the int array while calling the sort and finding the median

       Output(fArray, iArraySize);//outputing the float array while calling the sort and finding the median

       cout << " press anyKey to end program...";

       _getch();

}//end main

M2

#include "stdafx.h"

#include<iostream>

#include<string>

using namespace std;

inline void nameInputFunction(string name)

{

getline(cin, name);

}

//below is a template function to take user input for an array

//and array is passed here as a pointer

template<typename T>

void functionForArrayInput(T *array)

{

for (int i = 0; i < 5; ++i) //size of array is known and it is 5

cin >> array[i];

}

template<typename T>

void sortArray(T *arr) {

int i, j;

T key;

for (i = 1; i < 5; i++)

{

key = arr[i];

j = i - 1;

while (j >= 0 && arr[j] > key)

{

arr[j + 1] = arr[j];

j = j - 1;

}

arr[j + 1] = key;

}

}

void display(char name[]) {

cout << "User name is : ";

int i = 0;

while (name[1] != '') {

cout << name[i];

++i;

}

cout << endl;

}

void display(int array[]) {

cout << "Enterd integer array is : ";

int i = 0;

while (i < 5) {

cout << array[i] << " ";

++i;

}

cout << endl;

}

void display(float array[]) {

cout << "Enterd float array is : ";

int i = 0;

while (i < 5) {

cout << array[i] << " ";

++i;

}

cout << endl;

}

int main()

{

string name;

int int_array[5];

float float_array[5];

cout << "Enter user name : ";

nameInputFunction(name);

cout << "Please enter 5 element of int array : ";

functionForArrayInput(int_array);

cout << "Please enter 5 element of float array : ";

functionForArrayInput(float_array);

sortArray(int_array);

sortArray(float_array);

cout << "Your entered int array in sorted order is : ";

display(int_array);

cout << "Your entered float array in sorted order is : ";

display(float_array);

cout << "Median of both array is 3rd element in sorted array ";

cout << "Median of int array is : " << int_array[2] << endl;

cout << "Median of float array is : " << float_array[2] << endl;

return 0;

}

Explanation / Answer

1. Araay size is of 5 in both the M1 and M2.

2. Sorting order of float and int

1. Template is used in M2 but not in M1

2. Array value is passed as an pointer in M2 not in M1.

3. Using Inline function in M1.

4. function call in M2.

5. return value in M2 and not in M1.

Similarities Dissimilarities M1 and M2

1. Araay size is of 5 in both the M1 and M2.

2. Sorting order of float and int

1. Template is used in M2 but not in M1

2. Array value is passed as an pointer in M2 not in M1.

3. Using Inline function in M1.

4. function call in M2.

5. return value in M2 and not in M1.