Declare an array of integers: .data size: .word 8 array: .word 23, -12, 45, -32,
ID: 3813844 • Letter: D
Question
Declare an array of integers:
.data
size: .word 8
array: .word 23, -12, 45, -32, 52, -72, 8, 13
Write a program that determines the minimum and the maximum element in the array. Assume that the array has at least one element (in which case, that element will be both the minimum and maximum.) Leave the results in registers.
Array Maximum and Minimum Declare an array of integers data size word 8 array: .word 23, -12, 45, -32, 52, -72, 8, 13 Write a program that determines the minimum and the maximum element in the array. Assume that the array has at least one element (in which case, that element will be both the minimum and maximum.) Leave the results in registers.Explanation / Answer
since the language is not given, i am writing code in cpp
code:
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
int main()
{
int n;
int arr[1000];
cout<<"enter size of array: "<<endl;
cin>>n;
cout<<"enter array elements: "<<endl;
int i=0;
int min=10000;
int max= -10000;
for(i=0;i<n;i++)
{
int x;
cin>>x;
arr[i]=x;
if(x>max)
max =x;
if(x<min)
min=x;
}
cout<<"min element is :"<<min<<endl;
cout<<"max element is :"<<max<<endl;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.