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.
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])...
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.
Post a Python program that contains an array variable whose values are input by the user....
Post a Python program that contains an array variable whose values are input by the user. It should the perform some modification to each element of array using a loop and then the modified array should be displayed. Include comments in your program that describe what the program does. Also post a screen shot of executing your program on at least one test case.
Let A and B be two events. Find the largest and smallest possible values P(A U...
Let A and B be two events. Find the largest and smallest possible values P(A U B) can take in terms of P(A) and P(B) and give examples in which these values can be attained.
If P713 is divisible by 11, find the value of the smallest natural number P?
If P713 is divisible by 11, find the value of the smallest natural number P?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT