Question

In: Computer Science

Declare a 3x4 multidimensional array. Receive values for eachelement from user. Find the smallest value...

Declare a 3x4 multidimensional array. Receive values for each element from user. Find the smallest value in the multidimensional array, display its index and value, use array access operator [ ]. Find the largest value in the multidimensional array, display its index and value, use pointers. Write C code.

Solutions

Expert Solution

code:

#include
typedef int Array[3][4];
int main()
{
int a[3][4],i,j;
printf("Enter the values\n");
//get the values in to the array
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
scanf("%d",&a[i][j]);
}
}
//find the smallest value and the index
int value=a[0][0],row=0,column=0;
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
//condition to check the smallest value
if(a[i][j] {
value=a[i][j];
row=i;
column=j;
}
}
}
//print the smallest and the index values
printf("Smallest number is %d\n",value);
printf("Index is %d %d\n",row,column);
//assign a pointer to an array with nummvalue
Array *b =NULL;
//assign the values of a to pointer array
b=&a;
int value1=0,row1=0,column1=0;
for (i=0;i<3;i++) //Loop of row
{
for(j=0;j<4;j++)
{
//condition to check the largest number
if((*b)[i][j]>value1)
{
value1=(*b)[i][j];
row1=i;
column1=j;
}
//printf(" array elements = %d\n", (*b)[i][j]);
}
}
//print the values
printf("Largest element is : %d\n",value1);
printf("Index is : %d %d\n",row1,column1);
return 0;
}

output:


Related Solutions

implement in LEGV8 find the smallest value in an array.
implement in LEGV8 find the smallest value in an array.
Unix Create a script that will declare an array and assign four values from the command...
Unix Create a script that will declare an array and assign four values from the command line. 1. Use these four values - Paul, Ringo, George, John, - in that order 2. Display the content of the array, displaying the values in this format and this order The first array value is "John" The second array value is "Paul" The third array value is "George" The fourth array value is "Ringo"
Given an array of numbers, find the index of the smallest array element (the pivot), for...
Given an array of numbers, find the index of the smallest array element (the pivot), for which the sums of all elements to the left and to the right are equal. The array may not be reordered. Example arr=[1,2,3,4,6] the sum of the first three elements, 1+2+3=6. The value of the last element is 6. Using zero based indexing, arr[3]=4 is the pivot between the two subarrays. The index of the pivot is 3. Function Description Complete the function balancedSum...
Write a Java program that takes an array of 10 "Int" values from the user and...
Write a Java program that takes an array of 10 "Int" values from the user and determines if all the values are distinct or not. Return TRUE if all the values of the array are distinct and FALSE if otherwise.
Write a C program to Declare an integer array of size 10 with values initialized as...
Write a C program to Declare an integer array of size 10 with values initialized as follows. int intArray[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; Compute each item of a new array of same size derived from the above array by: adding first item (intArray[0]) of the array with 3rd, 2nd with 4th, 3rd with 5th and so on. For the last-but-one item intArray[8], add it with first item and for the last item (intArray[9])...
Develop a recursive algorithm to find the smallest and largest element in an array and trace...
Develop a recursive algorithm to find the smallest and largest element in an array and trace the recursive function with appropriate message. using c++ add comment to the code
Obtain 1337 values, at random, from a uniform distribution where the smallest possible value is 20...
Obtain 1337 values, at random, from a uniform distribution where the smallest possible value is 20 and the largest possible value is 40. Label the vector ex5. Also, consider ex5 the population. Report all R code
Use C Programming - Given an array of integers and a number K, find the smallest...
Use C Programming - Given an array of integers and a number K, find the smallest element in array greater than or equal to K. If such element exists in the array, display it otherwise display "-1". Example: Input:     8     1 3 4 7 8 9 9 10     5     where: First line represents the number of elements in the array. Second line represents the elements in the array. Third line represents the value of K. Output:     7 Explanation:...
In Java Find the second largest and second smallest element in a given array. You can...
In Java Find the second largest and second smallest element in a given array. You can hardcode/declare the array in your program.
Use c programing. Declare a new employee struct. Prompt the user to enter values for two-member...
Use c programing. Declare a new employee struct. Prompt the user to enter values for two-member data of the struct. Store struct data in employee struct. Use the calculate(raise_function) to increase employee salary and store the result in employee structure. Use print_ structure to print employee structure.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT