based on the source code provided in c, how could I find the max and min values of entries in array a and b.  Feel free to edit and provide comments of how I could fix it.  #include #include #include #define N 10 int main(void) {     int i,j,k,n, max, min;     float a[N], b[N],sum;     char key_hit;     do     {                      printf("Please input how many values are inside array a (from 2 to 10):");             scanf("%i", &n);     }while (n<2 || n>10);     printf("\n\nPlease enter array a values");     for(i=1; i<=n; i+=1)     {             printf("\narray a value %i. : ",i);       scanf("%f", &a[i]);     }     do     {                      printf("Please input how many values are inside array b (from 2 to 10):");             scanf("%i", &k);     }while (k<2 || k>10);     printf("\n\nPlease enter array b values");     for(j=1; j<=k; j+=1)     {             printf("\narray b value %i. : ",j);       scanf("%f", &b[j]);     }     printf("\n\nIs there anything choice you would like to do?");     printf("\nThe numbers related to the choices are listed below:");      printf("\n1. Max and min values of a.");     printf("\n2. Max and min values of b.");     printf("\n3. Dot product of a and b.");     printf("\n4. Review a specific value in the set.");     printf("\n5. End the program.");     printf("\nPlease enter your choice (the number): ");     scanf(" %c", &key_hit);     key_hit == '0';     switch(key_hit)     {         case '1':         min = a[0];         max = a[0];         for(i=0; i<=n; i++)         {            if(a[i] < min)          {           min = a[i+1];                      }          if(a[i] > max)          {             max = a[i];            }                  }          printf("\nThe max value entry in a is: %i", max);          printf("\nThe min value entry in a is: %i", min);          break;                  case '2':         min = b[0];         max = b[0];         for(j=0; j<=k; j++)         {            if(b[j] < min)          {           min = b[j];                      }          if(b[j] > max)          {             max = b[j];            }                  }          printf("\nThe max value entry in b is: %i", max);          printf("\nThe min value entry in b is: %i", min);          break;     }     return 0;

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

based on the source code provided in c, how could I find the max and min values of entries in array a and b.  Feel free to edit and provide comments of how I could fix it. 

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define N 10

int main(void)
{
    int i,j,k,n, max, min;
    float a[N], b[N],sum;
    char key_hit;
    do
    {
        
            printf("Please input how many values are inside array a (from 2 to 10):");
            scanf("%i", &n);
    }while (n<2 || n>10);
    printf("\n\nPlease enter array a values");
    for(i=1; i<=n; i+=1)
    {
     
      printf("\narray a value %i. : ",i);
      scanf("%f", &a[i]);
    }
    do
    {
        
            printf("Please input how many values are inside array b (from 2 to 10):");
            scanf("%i", &k);
    }while (k<2 || k>10);
    printf("\n\nPlease enter array b values");
    for(j=1; j<=k; j+=1)
    {
     
      printf("\narray b value %i. : ",j);
      scanf("%f", &b[j]);
    }
    printf("\n\nIs there anything choice you would like to do?");
    printf("\nThe numbers related to the choices are listed below:"); 
    printf("\n1. Max and min values of a.");
    printf("\n2. Max and min values of b.");
    printf("\n3. Dot product of a and b.");
    printf("\n4. Review a specific value in the set.");
    printf("\n5. End the program.");
    printf("\nPlease enter your choice (the number): ");
    scanf(" %c", &key_hit);
    key_hit == '0';
    switch(key_hit)
    {
        case '1':
        min = a[0];
        max = a[0];
        for(i=0; i<=n; i++)
        {  
         if(a[i] < min)
         {
          min = a[i+1];   
        
         }

         if(a[i] > max)
         {
            max = a[i];  
         }
        
        }
         printf("\nThe max value entry in a is: %i", max);
         printf("\nThe min value entry in a is: %i", min);
         break;
        
        case '2':
        min = b[0];
        max = b[0];
        for(j=0; j<=k; j++)
        {  
         if(b[j] < min)
         {
          min = b[j];   
        
         }

         if(b[j] > max)
         {
            max = b[j];  
         }
        
        }
         printf("\nThe max value entry in b is: %i", max);
         printf("\nThe min value entry in b is: %i", min);
         break;
    }
    return 0; 
}

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 4 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education