(** 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.
In C-
#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


Step by step
Solved in 2 steps with 7 images









