1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
MAVERICK [17]
3 years ago
10

Find the maximum value and minimum value in milesTracker. Assign the maximum value to maxMiles, and the minimum value to minMile

s. Sample output for the given program:Min miles: -10Max miles: 40#include using namespace std;int main( ) { const int NUM_ROWS = 2; const int NUM_COLS = 2; int milesTracker[NUM_ROWS][NUM_COLS]; int i = 0; int j = 0; int maxMiles = -99; // Assign with first element in milesTracker before loop int minMiles = -99; // Assign with first element in milesTracker before loop milesTracker[0][0] = -10; milesTracker[0][1] = 20; milesTracker[1][0] = 30; milesTracker[1][1] = 40; /* Your solution goes here */ cout << "Min miles: " << minMiles << endl; cout << "Max miles: " << maxMiles << endl;}
Computers and Technology
1 answer:
ryzh [129]3 years ago
6 0

Answer:

Following are th program in the C++ Programming Language.

#include <iostream>//set Header files

using namespace std;//set namespace

//define main function

int main()

{

//set integer constants variable

const int NUM_ROWS = 2;

//set integer constants variable

const int NUM_COLS = 2;

//set integer type array

int milesTracker[NUM_ROWS][NUM_COLS];

//set integer type variable and initialize to 0

int i = 0;

//set integer type variable and initialize to 0

int j = 0;

//set integer type variable and initialize to -99

int maxMiles = -99;

//set integer type variable and initialize to -99

int minMiles = -99;

//initialize the value in the two dimensional array

milesTracker[0][0] = -10;

milesTracker[0][1] = 20;

milesTracker[1][0] = 30;

milesTracker[1][1] = 40;

//here is the solution  

maxMiles = milesTracker[0][0];

minMiles = milesTracker[0][0];

/*set for loop to find the minimum miles and maximum miles*/

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

{

 for (j = 0; j < NUM_COLS; j++)

 {

 //set if condition for maxMiles is the bigger than

   if (milesTracker[i][j] > maxMiles)

   //initialize milesTracker[i][j] to maxMiles

     maxMiles = milesTracker[i][j];

   //set if condition for minMiles is the smaller than

   if (milesTracker[i][j] < minMiles)

   //initialize milesTracker[i][j] to maxMiles

     minMiles = milesTracker[i][j];

 }

}

//print output

cout << "Min miles: " << minMiles << endl;

//print output

cout << "Max miles: " << maxMiles << endl;

return 0;

}

<u>Output:</u>

Min miles: -10

Max miles: 40

Explanation:

Here, we define the main method and inside it:

  • set two constant integer type variable and initialize to 2
  • set integer type two-dimensional array and pass constant variables in it.
  • Set two integer type variable and initialize to 0 then, again set two integer type variable and initialize to -99.
  • Initialize the values in the two-dimensional array.
  • Set two for loop for the two-dimensional array to find the minimum and maximum miles.
  • Set two if condition to find bigger or smaller miles.

Finally, print the maximum and the minimum miles then, return 0.

You might be interested in
50 POINTS! What can be viewed in the Tasks folder? Check all that apply.
Rom4ik [11]

1, 2, and 4 :))) good luck

6 0
3 years ago
Read 2 more answers
Create a macro named mReadInt that reads a 16- or 32-bit signed integer from standard input and returns the value in an argument
timofeeve [1]

Answer:

;Macro mReadInt definition, which take two parameters

;one is the variable to save the number and other is the length

;of the number to read (2 for 16 bit and 4 for 32 bit) .

%macro mReadInt 2

mov eax,%2

cmp eax, "4"

je read2

cmp eax, "2"

je read1

read1:

mReadInt16 %1

cmp eax, "2"

je exitm

read2:

mReadInt32 %1

exitm:

xor eax, eax

%endmacro

;macro to read the 16 bit number, parameter is number variable

%macro mReadInt16 1

mov eax, 3

mov ebx, 2

mov ecx, %1

mov edx, 5

int 80h

%endmacro

;macro to read the 32 bit number, parameter is number variable

%macro mReadInt32 1

mov eax, 3

mov ebx, 2

mov ecx, %1

mov edx, 5

int 80h

%endmacro

;program to test the macro.

;data section, defining the user messages and lenths

section .data

userMsg db 'Please enter the 32 bit number: '

lenUserMsg equ $-userMsg

userMsg1 db 'Please enter the 16 bit number: '

lenUserMsg1 equ $-userMsg1

dispMsg db 'You have entered: '

lenDispMsg equ $-dispMsg

;.bss section to declare variables

section .bss

;num to read 32 bit number and num1 to rad 16-bit number

num resb 5

num1 resb 3

;.text section

section .text

;program start instruction

global _start

_start:

;Displaying the message to enter 32bit number

mov eax, 4

mov ebx, 1

mov ecx, userMsg

mov edx, lenUserMsg

int 80h

;calling the micro to read the number

mReadInt num, 4

;Printing the display message

mov eax, 4

mov ebx, 1

mov ecx, dispMsg

mov edx, lenDispMsg

int 80h

;Printing the 32-bit number

mov eax, 4

mov ebx, 1

mov ecx, num

mov edx, 4

int 80h

;displaying message to enter the 16 bit number

mov eax, 4

mov ebx, 1

mov ecx, userMsg1

mov edx, lenUserMsg1

int 80h

;macro call to read 16 bit number and to assign that number to num1

;mReadInt num1,2

;calling the display mesage function

mov eax, 4

mov ebx, 1

mov ecx, dispMsg

mov edx, lenDispMsg

int 80h

;Displaying the 16-bit number

mov eax, 4

mov ebx, 1

mov ecx, num1

mov edx, 2

int 80h

;exit from the loop

mov eax, 1

mov ebx, 0

int 80h

Explanation:

For an assembly code/language that has the conditions given in the question, the program that tests the macro, passing it operands of various sizes is given below;

;Macro mReadInt definition, which take two parameters

;one is the variable to save the number and other is the length

;of the number to read (2 for 16 bit and 4 for 32 bit) .

%macro mReadInt 2

mov eax,%2

cmp eax, "4"

je read2

cmp eax, "2"

je read1

read1:

mReadInt16 %1

cmp eax, "2"

je exitm

read2:

mReadInt32 %1

exitm:

xor eax, eax

%endmacro

;macro to read the 16 bit number, parameter is number variable

%macro mReadInt16 1

mov eax, 3

mov ebx, 2

mov ecx, %1

mov edx, 5

int 80h

%endmacro

;macro to read the 32 bit number, parameter is number variable

%macro mReadInt32 1

mov eax, 3

mov ebx, 2

mov ecx, %1

mov edx, 5

int 80h

%endmacro

;program to test the macro.

;data section, defining the user messages and lenths

section .data

userMsg db 'Please enter the 32 bit number: '

lenUserMsg equ $-userMsg

userMsg1 db 'Please enter the 16 bit number: '

lenUserMsg1 equ $-userMsg1

dispMsg db 'You have entered: '

lenDispMsg equ $-dispMsg

;.bss section to declare variables

section .bss

;num to read 32 bit number and num1 to rad 16-bit number

num resb 5

num1 resb 3

;.text section

section .text

;program start instruction

global _start

_start:

;Displaying the message to enter 32bit number

mov eax, 4

mov ebx, 1

mov ecx, userMsg

mov edx, lenUserMsg

int 80h

;calling the micro to read the number

mReadInt num, 4

;Printing the display message

mov eax, 4

mov ebx, 1

mov ecx, dispMsg

mov edx, lenDispMsg

int 80h

;Printing the 32-bit number

mov eax, 4

mov ebx, 1

mov ecx, num

mov edx, 4

int 80h

;displaying message to enter the 16 bit number

mov eax, 4

mov ebx, 1

mov ecx, userMsg1

mov edx, lenUserMsg1

int 80h

;macro call to read 16 bit number and to assign that number to num1

;mReadInt num1,2

;calling the display mesage function

mov eax, 4

mov ebx, 1

mov ecx, dispMsg

mov edx, lenDispMsg

int 80h

;Displaying the 16-bit number

mov eax, 4

mov ebx, 1

mov ecx, num1

mov edx, 2

int 80h

;exit from the loop

mov eax, 1

mov ebx, 0

int 80h

7 0
3 years ago
Students can use eNotes to type notes directly on screen and
zalisa [80]
A. review or print them later
6 0
3 years ago
Read 2 more answers
at the bank there is 4 lines with 7 costumers and there are five customers left over. how many customers are there​
mrs_skeptik [129]
Answer: 33
7 times 4 is 28 add the left over 5 makes 33 people
4 0
2 years ago
Four categories of installer apps
Naddika [18.5K]

Answer:

I find 5 categories

Explanation:

1 Overview

2 Necessity

3 Types

4 Attended installation

4.1 Silent installation

4.2 Unattended installation

4.3 Headless installation

4.4 Scheduled or automated installation

4.5 Clean installation

4.6 Network installation

5 Installer

5.1 Bootstrapper

5.2 Common types

5.3 System installer

7 0
3 years ago
Other questions:
  • The house had a wonderful pool of ... (his/its/our) own.​
    5·1 answer
  • Which routine is configured to be called by another routine?
    10·1 answer
  • An iframe is an inline table for a website. True False i need an answer fast
    15·1 answer
  • Does Windows 7 support secure boot in UEFI? Windows eight? Linux UBUNTU version 14?
    8·1 answer
  • There are three types of value for money. Which of the following is not a method of value?
    14·1 answer
  • ⭐️⭐️⭐️ what Network is larger in size? MAN or WAN? Thank you ⭐️⭐️⭐️
    5·1 answer
  • The main disadvantage of using this device is its negative impact on network performance,resulting from the fact that any incomi
    10·1 answer
  • Set screw compression and indenter are all types of
    13·2 answers
  • when inputting a formula into excel or other spreadsheet software, what components are required for the formula to function prop
    8·1 answer
  • an engineer is writing a web application that requires some user input. the engineer has put a submit button on their page and n
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!