107k views
0 votes
You are given an array x of string elements along with an int variable n that contains the number of elements in the array. You are also given a string variable mode that has been declared. Assign to mode the mode value of the array. (Assume there are no "ties".)

User Bharath
by
5.3k points

1 Answer

3 votes

Answer and Explanation:

Make an algorithm of that which include array x of string where Mode of the value of the array means that you have the values such that 1.2,4,2,6,7,8,2 so 2 is the value of set as it appears more than other number similarly when a array of x has been given.First of all initialize a variable then declare it . so for initialization create a variable .Let suppose i create a variable of add and initialize it with 0 and given a it data type integer then

int add= 0; // declaration

int add[]=0; // declaration and initialization in array

class add {

void main(String array[]){

int add[]=0;//declaration and instantiation

int add[] = new int [3];

add[0]=30;//initialization

add[1]=80;

add[2]=20;

output the given array of string

for ( int i = 0 ; i <add.length ;i++)

cout <<add[i];

}

Taking an other example let initialization and declare array of string and print the greater value.For this create a variable with integer data type \

class Test{

void main(String[] array){

//declaration of array

int test[][] = new int [2];

test[0]; new int [2];

test[1]; new int [4];

for initialization of array lets take variable a with data type integer

int a=0;

//taking loop for condition

for (int i=0; i<test.length; i++)

for(int j=0; j<test[i].length; j++)

//if the loops working properly then take increment in the variable a

test[i][j] = a++;

this process repeat until loops got false

for (int i=0; i<test.length; i++)

for(int j=0; j<test[i].length; j++)

cout<<test[i][j]<<"+"<<"";

}

System.out.println();

}

}

User Rosalva
by
5.4k points