*Try the program then answer the questions below*
PROGRAM:
#includeusing namespace std;int main (){int arr[10], num, x, y, z, highest, lowest;cout < "\nenter="" the="" number="" of="" items="" to="" sort:="">cin >> num;cout < "enter="" the="" numbers:="">for (x = 0; x < num;="">cin >> arr[x];highest = arr[0];for (x = 0; x < num;="">{if (highest <>highest = arr[x];}lowest = arr[0];for (x = 0; x < num;="">{if (lowest > arr[x])lowest = arr[x];}for(x=0; x{for(y=x+1; y{if(arr[x]>arr[y]){z =arr[x];arr[x]=arr[y];arr[y]= z;}}}cout < "\n="">cout < "="">cout<"\nlowest -=""> Highest:"<>for(x=0; xcout <><><">">cout<>for(x=0;x<>{for(y=x+1;y<>{if(arr[x]<>{z = arr[x];arr[x]=arr[y];arr[y]= z;}}}cout<"\n\nhighest -=""> Lowest:"<>for(x=0; xcout <><><">">cout<>cout < "\n="">cout < "="">cout < "\nhighest="" number="" :="" "="">< highest=""><>cout < "lowest="" number="" :="" "="">< lowest=""><>return 0;}QUESTIONS:1.) Can this program be done with only 1 integer array being used? Explain your answer.2.) Explain how the program was able to determine the highest and lowest element."\n\nhighest>"\nlowest>
int main (){int arr[10], num, x, y, z, highest, lowest;cout < "\nenter="" the="" number="" of="" items="" to="" sort:="">cin >> num;cout < "enter="" the="" numbers:="">
for (x = 0; x < num;="">cin >> arr[x];highest = arr[0];
for (x = 0; x < num;="">{if (highest <>highest = arr[x];}lowest = arr[0];for (x = 0; x < num;="">{if (lowest > arr[x])lowest = arr[x];}
for(x=0; x{for(y=x+1; y{if(arr[x]>arr[y]){z =arr[x];arr[x]=arr[y];arr[y]= z;}}}cout < "\n="">cout < "="">cout<"\nlowest -=""> Highest:"<>for(x=0; xcout <><><">">cout<>for(x=0;x<>{for(y=x+1;y<>{if(arr[x]<>{z = arr[x];arr[x]=arr[y];arr[y]= z;}}}cout<"\n\nhighest -=""> Lowest:"<>for(x=0; xcout <><><">">cout<>cout < "\n="">cout < "="">cout < "\nhighest="" number="" :="" "="">< highest=""><>cout < "lowest="" number="" :="" "="">< lowest=""><>return 0;
}
QUESTIONS:
1.) Can this program be done with only 1 integer array being used? Explain your answer.
2.) Explain how the program was able to determine the highest and lowest element.
"\n\nhighest>"\nlowest>
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here