Question

In: Computer Science

How to print the element in the fifth row and seventh column given this array declaration...

How to print the element in the fifth row and seventh column given this array declaration in dev c:

int hello[5][10];

Solutions

Expert Solution

#include <stdio.h>
// main function
int main()
{
// declare the array
int hello[5][10];
// to print the element at fifth row and seventh column we print the element at [5-1][7-1] i.e. [4][6] index because the index starts from [0][0]
printf("Element at 5th row and 7th column : %d\n",hello[4][6]);
// the output will be some garbage value because we have not populated the array yet
// now lets populate the array with some values
for(int i=0;i<5;i++)
{
for(int j=0;j<10;j++)
{
hello[i][j]=i+j;
}
}
// now print the value at fifth row and seventh column it should print (5-1) + (7-1) = 4 + 6 = 10
printf("Element at 5th row and 7th column : %d\n",hello[4][6]);
return 0;
}


Related Solutions

write a function declaration for a 2d array where each row size is 8 and the...
write a function declaration for a 2d array where each row size is 8 and the function does not return anything.
Write a function declaration for a function that sums each row of a 2D array, where...
Write a function declaration for a function that sums each row of a 2D array, where each row size is 10. The function does not return a result. IN C Program.
Write a function declaration for a function that sums each row of a 2D array, where...
Write a function declaration for a function that sums each row of a 2D array, where each row size is 10. The function does not return a result. Need it in 10 minutes, please.
for input matrix a , write a function to return the element in row 2 column...
for input matrix a , write a function to return the element in row 2 column 3 of that matrix
Write a function called ReturnOddEntries.m that accepts as input a column or row array (vector) and...
Write a function called ReturnOddEntries.m that accepts as input a column or row array (vector) and returns only the odd index entries. Do this by first setting the even entries to 0, and then removing the 0 entries by using a logical array. The first line of your code should read function p = ReturnOddEntries(p) For example, if you run in the command window p = ReturnOddEntries([1.2 7.1 8.4 -42 100.1 7 -2 4 6]), then you should get p...
Write a function script DirCos.m that takes a vector (any row or column array) as the...
Write a function script DirCos.m that takes a vector (any row or column array) as the argument and returns the direction cosines for that vector. This is for a MatLab script
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...
Given an array, return the element at which the "pattern" breaks. For example, in the array...
Given an array, return the element at which the "pattern" breaks. For example, in the array [2,4,6,8,11,13,15,17], the algorithm should return 11 because the difference between every previous node was 2, and the difference between 8 and 11 is 3. PLEASE USE DIVIDE AND CONQUER. Thank you. Python please or just a description of the algorithm
How are the column space and the row space of a matrix A related to the...
How are the column space and the row space of a matrix A related to the column space and row space of its reduced row echelon form? How does this prove the column rank of A equals the row rank?
Complete the given C++ program (prob1.cpp) to read an array of integers, print the array, and...
Complete the given C++ program (prob1.cpp) to read an array of integers, print the array, and then find the index of the largest element in the array. You are to write two functions, printArray() and getIndexLargest(), which are called from the main function. printArray() outputs integers to std::cout with a space in between numbers and a newline at the end. getIndexLargest () returns the index of the largest element in the array. Recall that indexes start at 0. If there...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT