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;...

  • 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...

  • 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 +...

  • For any element in keysList with a value greater than 50. print the corresponding value in...

    For any element in keysList with a value greater than 50. print the corresponding value in itemsList, followed by a comma (no spaces) Ex: If the input is 32 105 101 35 10 20 30 40 the output is 20,30, 1 include <stdio.h> 2 3 int main(void) { 4 const int SIZE LIST - 4 5 int keysList[SIZE LISTI: 6 int itemslist[SIZE_LIST); 7 int 1; 8 9 scanf("%d", &keysList[0]); 10 scanf("%d", &keyslist[1]); 11 scanf("%d", &keysList[2]); 12 scanf("%d", &keysList[]); 13 14...

  • 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];...

  • package Lab11; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; public class Lab10 {    public...

    package Lab11; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; public class Lab10 {    public static void main (String [] args)    {    // ============================================================    // Step 2. Declaring Variables You Need    // These constants are used to define 2D array and loop conditions    final int NUM_ROWS = 4;    final int NUM_COLS = 3;            String filename = "Input.txt";    // A String variable used to save the lines read from input...

  • 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...

  • I have to write a C program to assign seats on each flight of the airline’s...

    I have to write a C program to assign seats on each flight of the airline’s only plane (capacity: 40 seats, in 10 rows). For the sake of simplicity, assume that each row has 4 seats labeled A, B, C, D. Your program should display the following menu of alternatives: Please type 1 for "first class" Please type 2 for "business class" Please type 3 for “economy class”. If the person types 1, then your program should assign a seat...

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
ADVERTISEMENT