Perform the functionality of 2-D array through 1-D array
and in it the functions to be performed were:
(1) Display the array in 2-D format
(2) Display a particular element
(3) Display a particular row
(4) Display a particular column
Answer Posted / sandeep
#include<stdio.h>
#include<conio.h>
void main()
{
static int *arr[5],arr1[5],arr2[5],arr3[5],arr4[5],arr5[5];
int *temp;
clrscr();
arr[0]=arr1;
arr[1]=arr2;
arr[2]=arr3;
arr[3]=arr4;
arr[4]=arr5;
for(i=0;i<5;i++)
{
for(int j=0;j<5;j++)
printf("%d ",arr[i][j]);
printf("\n");
}
getch();
}
| Is This Answer Correct ? | 6 Yes | 4 No |
Post New Answer View All Answers
Definition of priority queue was given. We have to implement the priority queue using array of pointers with the priorities given in the range 1..n. The array could be accessed using the variable top. The list corresponding to the array elements contains the items having the priority as the array index. Adding an item would require changing the value of top if it has higher priority than top. Extracting an item would require deleting the first element from the corresponding queue. The following class was given: class PriorityQueue { int *Data[100]; int top; public: void put(int item, int priority); // inserts the item with the given priority. int get(int priority); // extract the element with the given priority. int count(); // returns the total elements in the priority queue. int isEmpty(); // check whether the priority queue is empty or not. }; We had to implement all these class functions.
Write a program that print in screen a tree with its height taken from user by entering number of 4 digits and find the odd numbers then calculate the sum of odd numbers so he get the height of tree?
write a program to perform generic sort in arrays?
write a program to convert temperature from fa height into celcius and vise versa,use modular programming
write a function that reverse the elements of an array in place.The function must accept only one pointer value and return void.
Performance Algorithm A performs 10n2 basic operations and algorithm B performs 300 lg n basic operations. For what value of n does algorithm B start to show its better performance?
find level of following tree (state, parent) " J,D I,D H,C E,B F,B G,C B,A D,A C,A A,& K,E L,E L,F M,F N,G O,H P,I P,H Q,I R,J S,K U,P T,L
write a program that prompt the user to enter his height and weight,then calculate the body mass index and show the algorithm used
write a program that creates a sequenced array of numbers starting with 1 and alternately add 1 and then 2 to create the text number in the series , as shown below. 1,33,4,6,7,9,............147,148,150 Then , using a binary search , searches the array 100 times using randomly generated targets in the range of 1 to 150
A suduco given & u hv 2 check if it is incomplete(blanks left),or correct or incorrect
Code for Small C++ Class to Transform Any Static Control into a Hyperlink Control?
write a program using virtual function to find the transposing of a square matrix?
create a stucture student containing field for roll no,class,year and marks.create 10 student annd store them in a file
write a program that reverses the input number of n.Formulate an equation to come up with the answer.
can you please write a program for deadlock that can detect deadlock and to prevent deadlock.