Question

Please solve this C language progrm (2-D Array program) the most basic way ! Thank You!...

Please solve this C language progrm (2-D Array program) the most basic way !

Thank You!

Write a function that takes a 4 x 4 array of integers as its parameter. The function must use two nested for-loops to determine the largest integer in the array as well as its row and column numbers. Recall that C-functions cannot return multiple values. Use pointers in the function parameter list to relay the results to the caller program.

Write another function, which uses a 4 x 4 array of integers as its input/output parameter. The function prompts the user to enter 16 integers and stores them into 4 x 4 array.

Write the main function that uses the above function to input a 4 x 4 array and find its largest element and its row and column location. Prints the results.

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

#include<stdio.h>
#include<conio.h>

main()
{
   int m, n, c, d, matrix[10][10], maximum;
   int row,column;
   printf("Enter the number of rows and columns of matrix\n");
   scanf("%d%d",&m,&n);
   printf("Enter the elements of matrix\n");

   for( c = 0 ; c < m ; c++ )
   {
      for( d = 0 ; d < n ; d++ )
      {
         scanf("%d",&matrix[c][d]);
      }
   }

   maximum = matrix[0][0];

   for( c = 0 ; c < m ; c++ )
   {
      for( d = 0 ; d < n ; d++ )
      {
         if ( matrix[c][d] > maximum )
            {maximum = matrix[c][d];
            row=c;
            column=d;
            }
      }
   }

   printf("Maximum element in matrix is %d\n", maximum);
   printf("\n The row number is :: %d",row+1);
   printf("\n The column number is :: %d",column);
   getch();
   return 0;
}


A:\Prog_links_codes sample_coding\Test project1\main.exe nter the number of rows and columns of matrix 4 Enter the elements o

Add a comment
Know the answer?
Add Answer to:
Please solve this C language progrm (2-D Array program) the most basic way ! Thank You!...
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
  • IN C#.Develop a program that prints out the location of the largest value in a two-dimensional...

    IN C#.Develop a program that prints out the location of the largest value in a two-dimensional array. The largest values may appear more than once in the array, so you must only print out the first instance. The program defines method locateLargest() that takes a two-dimensional array of integers and returns the location (row index and column index) of the first largest value as a single-dimensional array. The program main method prompts the user to enter a 3-by-4 matrix, prints...

  • SOLVE IN PYTHON: Exercise #2: Develop a program (name it LocateLargestElement) that prints out the location...

    SOLVE IN PYTHON: Exercise #2: Develop a program (name it LocateLargestElement) that prints out the location of the first largest value in a two-dimensional array. The largest values may appear more than once in the array. The program defines method locateLargest() that takes a two-dimensional array of integers and returns the location (row index and column index) of the first largest value as a single-dimensional array. The program main method prompts the user to enter a 3-by-4 matrix, prints out...

  • Please solve this question using c++ language Problem 2. More Probleml. The program builds the array...

    Please solve this question using c++ language Problem 2. More Probleml. The program builds the array of integers that contains duplicates as well. Your program should find the sum of all unique elements in the array using a function findUniqueSum Arrays Write a program that as before asks the user to enter input as in оn Sample Input/Output Enter a list of numbers ending with -999 3 1 4 55-999 The sum of unique numbers is: 13 Enter a list...

  • Please help C++ language Instructions Write a program that prompts the user to enter 50 integers...

    Please help C++ language Instructions Write a program that prompts the user to enter 50 integers and stores them in an array. The program then determines and outputs which numbers in the array are sum of two other array elements. If an array element is the sum of two other array elements, then for this array element, the program should output all such pairs.

  • Write a program in C++ language that finds the largest number in an array of positive...

    Write a program in C++ language that finds the largest number in an array of positive numbers using recursion. Your program should have a function called array_max that should pass in an int array, and an int for the size of the array, respectively, and should return an int value. As an example, given an array of size 10 with contents: {10, 9, 6, 1, 2, 4, 16, 8, 7, 5} The output should be: The largest number in the...

  • Three C Code Questions: 5. Write a C program that declares an array of 10 strings,...

    Three C Code Questions: 5. Write a C program that declares an array of 10 strings, each of max length 50 characters, and then reads an entire line of text from the keyboard into each string. 6. Write C code that finds the longest name in this array of strings that you read in Q5. Hint: find the position of the longest string, not the string itself. 7. Write a C program that creates a 4 x 6 two dimensional...

  • C++ program Write a program which: 1. Enters data into the 2D array of integers which...

    C++ program Write a program which: 1. Enters data into the 2D array of integers which is 5x5 The data should be entered with an assignment statement using nested for loops that is do not scan in the data. The data should be: 1 2 4 8 16 1 3 9 27 81 1 4 16 64 256 1 5 25 125 625 1 6 36 216 1296 2. Print out the following using a nested for loop Row 0:...

  • Use C Programming DESCRIPTION Write a program that: Creates a Dimensional, integer array that holds 8...

    Use C Programming DESCRIPTION Write a program that: Creates a Dimensional, integer array that holds 8 values Prompts the user to enter 8 integers between 0 and 20 [inclusive) and stores the data in the array Prints the data in array abng with a histogram of the data as shown below. There is no requirement to validate the data. You must use a constant to declare your array and control any loops you need Sample Output: Enter 8 integer values...

  • this language is JAVA 2. Design a class named Location for locating a maximum value and...

    this language is JAVA 2. Design a class named Location for locating a maximum value and its location in a two-dimensional array. The class contains public data fields row, column, and maxValue that store the maximal value and its indices in a two-dimensional array with row and column as int types and maxValue as a double type. Write the following method that returns the location of the largest element in a two-dimensional array: Public static Location locateLargest(double [][] a) Create...

  • In C++ please! Please include .cpp and .hpp files! Thank you! Recursive Functions Goals Create and...

    In C++ please! Please include .cpp and .hpp files! Thank you! Recursive Functions Goals Create and use recursive functions In this lab, we will write a program that uses three recursive functions. Requirements: Important: You must use the array for this lab, no vectors allowed. First Recursive Function Write a function that recursively prints a string in reverse. The function has ONLY one parameter of type string. It prints the reversed character to the screen followed by a newline character....

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