Question

Find the maximum value and minimum value in miles Tracker. Assign the maximum value to maxMiles, and the minimum value to minIN C PLEASE

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

#include <stdio.h>

int main()
{
const int NUM_ROWS=2; //const means NUM_ROWS cannot be reassigned
const int NUM_COLS=2; //const means NUM_COLS cannot be reassigned
int milesTracker[NUM_ROWS][NUM_COLS];
int i; //Interger Variable declaration
int j; //Interger Variable declaration

  
for(i=0;i<NUM_ROWS;i++) //loop for user input for rows
{
for(j=0;j<NUM_COLS;j++) //loop for user input for columns
{
printf("Enter value for milesTracker[%d][%d]:", i, j);
scanf("%d",&(milesTracker[i][j]));
}
}
  
int maxMiles = milesTracker[0][0]; //maxMiles value initialization
int minMiles = milesTracker[0][0]; //minMiles value initialization
  
for(i=0;i<NUM_ROWS;i++)
{
for(j=0;j<NUM_COLS;j++)
{
if(maxMiles<milesTracker[i][j]) //condition to check if maxMiles is less then the rest of the elements
{
maxMiles = milesTracker[i][j];
}
if(minMiles>milesTracker[i][j]) //condition to check if minMiles is greater then the rest of the elements
{
minMiles = milesTracker[i][j];
}
}
}
  
printf("Min miles: %d \n",minMiles); //Display of result
printf("Max miles: %d \n",maxMiles); //Display of result
  
return 0;
}


Screenshot of the code:

#include <stdio.h> int main() { const int NUM_ROWS=2; //const means NUM_ROWS cannot be reassigned const int NUM_COLS=2; //con

int maxMiles = milesTracker[@][@]; //maxMiles value initialization int minMiles = milesTracker[@][@]; //minMiles value initia

Screenshot of the output:

Enter value for milesTracker[0] [O]: 8 Enter value for milesTracker[0][1]:23 Enter value for milesTracker[1] [O]:-10 Enter va

Add a comment
Know the answer?
Add Answer to:
IN C PLEASE Find the maximum value and minimum value in miles Tracker. Assign the maximum...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Find the maximum value and minimum value in milesTracker. Assign the maximum value to maxMiles, and...

    Find the maximum value and minimum value in milesTracker. Assign the maximum value to maxMiles, and the minimum value to minMiles. Sample output for the given program: Min miles: -10 Max miles: 40 import java.util.Scanner; public class ArraysKeyValue { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); final int NUM_ROWS = 2; final int NUM_COLS = 2; int [][] milesTracker = new int[NUM_ROWS][NUM_COLS]; int i; int j; int maxMiles; // Assign with first element in...

  • IN JAVA Task: Find the maximum value and minimum value in milesTracker. Assign the maximum value...

    IN JAVA Task: Find the maximum value and minimum value in milesTracker. Assign the maximum value to maxMiles, and the minimum value to minMiles. Sample output for the given program: Min miles: -10 Max miles: 40 Given Code: import java.util.Scanner; public class ArraysKeyValue { public static void main (String [] args) { final int NUM_ROWS = 2; final int NUM_COLS = 2; int [][] milesTracker = new int[NUM_ROWS][NUM_COLS]; int i = 0; int j = 0; int maxMiles = 0;...

  • 7.9.1: Find 2D array max and min. Find the maximum value and minimum value in milesTracker....

    7.9.1: Find 2D array max and min. Find the maximum value and minimum value in milesTracker. Assign the maximum value to maxMiles, and the minimum value to minMiles. Sample output for the given program: Min miles: -10 Max miles: 40 import java.util.Scanner; public class ArraysKeyValue { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); final int NUM_ROWS = 2; final int NUM_COLS = 2; int [][] milesTracker = new int[NUM_ROWS][NUM_COLS]; int i; int j; int...

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

    Find the maximum value and minimum value in milesTracker. Assign the maximum value to maxMiles, and the minimum value to minMiles. Sample output for the given program: Find the maximum value and minimum value in miles Tracker. Assign the maximum value to maxMiles, and the minimum value to minMiles. Sample output for the given program Min miles: -10 Max miles: 40 (Notes) 1 import java.util.Scanner 3 public class ArraysKeyValue 4 public static void main (String passe args) i final int...

  • for c CHALLENGE ACTIVITY 9.7.1: Decrement array elements. Write a loop that subtracts 1 from each...

    for c CHALLENGE ACTIVITY 9.7.1: Decrement array elements. Write a loop that subtracts 1 from each element in lowerScores. If the element was already 0 or negative, assign 0 to the element. Ex lowerScores = {5,0,2,-3) becomes {4.0, 1.0). 1 include <stdio.h> 3 int main(void) 0 const int SCORES_SIZE - 4; int lowerScores [SCORES_SIZE]: int i; for (1 - 0; i < SCORES_SIZE; ++) { scanf("%d", &(lowerScores[i])); /" Your solution goes here / { 15 for (i = 0; i...

  • Working in C, modify the algorithm created in the Topic 1 assignment "Non-Linear Flow Chart" to...

    Working in C, modify the algorithm created in the Topic 1 assignment "Non-Linear Flow Chart" to instead compute the nth term in the series by calling a recursive function. Note that the value of "n" will need to be an input argument, along with the two starting values of the series. Discuss the efficiency of this method versus the iterative logic that you wrote previously. Previous Code: //main.c #include<stdio.h> #include<limits.h> int main() {    //declare a integer data type variales...

  • C - Language Write a loop that sets each array element to the sum of itself...

    C - Language Write a loop that sets each array element to the sum of itself and the next element, except for the last element which stays the same. Be careful not to index beyond the last element. Ex: Initial scores: 10, 20, 30, 40 Scores after the loop: 30, 50, 70, 40 The first element is 30 or 10 + 20, the second element is 50 or 20 + 30, and the third element is 70 or 30 +...

  • What is the run-time of this recursive code: int maximum(int array[], int index, int len); //define...

    What is the run-time of this recursive code: int maximum(int array[], int index, int len); //define maximum function. int minimum(int array[], int index, int len);//define minimum function. int main() { //Main method int array[MAX_SIZE], N, max, min; //Defining all the variable. int i; printf("Enter size of the array: ");//Taking input from user as a array size scanf("%d", &N); printf("Enter %d elements in array: ", N);//Taking input from user for(i=0; i<N; i++) { scanf("%d", &array[i]);//storing all the element in array. }...

  • When outputting the path found in the proposed program, the direction of movement is output. Howe...

    When outputting the path found in the proposed program, the direction of movement is output. However, the direction of movement to the last movement, EXIT, is not output. To print this out, please describe how to modify the proposed program. #include <stdio.h> #define NUM_ROWS 5 #define NUM_COLS 3 #define BOUNDARY_COLS 5 #define MAX_STACK_SIZE 100 #define FALSE 0 #define TRUE 1 ​ ​ ​ typedef struct { short int row; short int col; short int dir; } element; ​ element stack[MAX_STACK_SIZE];...

  • a. Write a function named findmax() that finds and displays the maximum values in a two...

    a. Write a function named findmax() that finds and displays the maximum values in a two dimensional array of integers. The array should be declared as a 10 row by 20 column array of integers in main() and populated with random numbers between 0 and 100. b. Modify the function written above so that it also displays the row and column numbers of the element with the maximum value. I have this so far, and but it's only finding the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT