Computer Science, asked by shoptorshiMondal, 8 months ago

Write a program to accept numbers in a 4×4 matrix, then print the all prime numbers present in the matrix with array Index value.
SAMPLE DATA:
INPUT:
16 15 1 2
6 4 10 14
9 8 12 5
3 7 11 13
OUTPUT:
PRIME ROW INDEX COLUMN INDEX
2 0 3
3 3 0
5 2 3
7 3 1
11 3 2
13 3 3

Answers

Answered by adityasrivastava6578
1

Answer:

int n[6];

n[ ] is used to denote an array 'n'. It means that 'n' is an array.

So, int n[6] means that 'n' is an array of 6 integers. Here, 6 is the size of the array i.e. there are 6 elements in the array 'n'.

Explanation:

By writing int n[ ]={ 2,4,8 }; , we are declaring and assigning values to the array at the same time, thus initializing it.

But when we declare an array like int n[3];, we need to assign values to it separately. Because 'int n[3];' will definitely allocate space of 3 integers in memory but there are no integers in that space.

 

To initialize it, assign a value to each of the elements of the array.

n[0] = 2;

n[1] = 4;

n[2] = 8;

It is just like we are declaring some variables and then assigning values to them.

int x,y,z;

x=2;

y=4;

z=8;

Thus, the first way of assigning values to the elements of an array is by doing so at the time of its declaration.

int n[ ]={ 2,4,8 };

Similar questions