(** Here is my issue I need help on how I can put a repetition in. For example I choose case 1,then case 1 executes then the user should have a choice to continue or not.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

In  C-programming. Below will be my code:

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define NROWS 5
#define NCOLS 5

int main(void)
{
   
    int i,j, max, min, m, n, max_1, max_2;
    float M[NROWS][NCOLS], Mt[NROWS][NCOLS];
    char key_hit, More_ops;
    //Input the sizes
    printf("ROW size(1-5) :   ");scanf("%d",&m);
    printf("Column size(1-5): ");scanf("%d",&n);
    
    //Size Check 
    while(m>NROWS || n>NCOLS)
    {
        printf("Please re-enter the sizes. \n");
        printf("Row size(1-5)   :  ");scanf("%d", &m);
        printf("Column size(1-5) : ");scanf("%d", &n);
    }
    
    //Input the Matrix Data 
    for(i=0; i<m; i++)
    {
        for(j=0; j<n; j++)
        {
           printf("M[%d][%d] = ", i,j);
           scanf("%f", &M[i][j]);
        }
    }
    //Print the Matrix Data 
    for(i=0; i<m; i++)
    {
        for(j=0; j<n; j++)
        {
            printf("%1.2f\t", M[i][j]);
        }
        printf("\n");
                   
    }
    //Choices of matrix operations
          printf("\n\nPlease choose an operation.");
          printf("\n1. Display The matrix M.");
          printf("\n2. Display The Matrix and its transpose.");
          printf("\n3. Max and min Values of array.");
          printf("\n4. End the program.");
          printf("\nYour choice (1-4): ");
          scanf(" %c", &key_hit);
         do{
          switch(key_hit)
          {
             case '1':
          //Option 1. Display Matrix M
             printf("M is  = ");
             for(i=0; i<m; i++)
              {
                for(j=0; j<n; j++)
                 {
                     printf("%.2f\t", M[i][j]);
                 }    
                   printf("\n\t");
              }
              break;
          // Transpose of Matrix M
          case '2':
          
             printf("M is  = ");
             for(i=0; i<m; i++)
              {
                for(j=0; j<n; j++)
                 {
                     printf("%.2f\t", M[i][j]);
                 }    
                   printf("\n\t");
              }
             printf("\nM - Transpose is      = ");
             for(i=0; i<m; i++)
              {
                 for(j=0; j<n; j++)
                  {
                     Mt[i][j] = M[j][i];
                     printf("%.2f\t", Mt[i][j]);
                  }
                  printf("\n\t\t\t");
              }
          break;
         //Min and Max values of Columns
         case '3':
         
              printf("M is  = ");
             for(i=0; i<m; i++)
              {
                for(j=0; j<n; j++)
                 {
                     printf("%.2f\t", M[i][j]);
                 }    
               printf("\n\t");
              }
               printf("\nMax values");
             for(i=0;i<m;i++)
                { max_1 = M[0][i];
                  for(j=0;j<n;j++)
                     { 
                       if(max_1 < M[j][i])
                         {
        
                            max_1 = M[j][i]; 
                         }
                     }
                
                  printf("  %i\t", max_1);
                }
          break;
          }
          while(key_hit != '4');
return 0; 
}

(** Here is my issue I need help on how I can put a repetition in. For example I choose case 1,then case 1 executes then the user should have a choice to continue or not. 

Below will be an image example

 

 

Please choose an operation.
1. Just display the matrix
2. Display the matrix and its transpose
3. Find max value of each column
4. Exit

Your choice (1 - 4): 3

M is:
```
1.23   3.42  -3.40   1.11
1.09  -5.60  -0.40   3.40
2.30   7.60   5.00  11.00
```

Max value:
```
2.30   7.60   5.00  11.00
```

More operation (Y/N)? Y

Please choose an operation.
1. Just display the matrix
2. Display the matrix and its transpose
3. Find max value of each column
4. Exit
Transcribed Image Text:Please choose an operation. 1. Just display the matrix 2. Display the matrix and its transpose 3. Find max value of each column 4. Exit Your choice (1 - 4): 3 M is: ``` 1.23 3.42 -3.40 1.11 1.09 -5.60 -0.40 3.40 2.30 7.60 5.00 11.00 ``` Max value: ``` 2.30 7.60 5.00 11.00 ``` More operation (Y/N)? Y Please choose an operation. 1. Just display the matrix 2. Display the matrix and its transpose 3. Find max value of each column 4. Exit
Expert Solution
steps

Step by step

Solved in 2 steps with 7 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY