Sir,

I want to multiply a 2-D array of size 100 by 100

a[100] * b[100];

or a[100][100];

What is the way to multiply the two arrays.

Ashwin Perti

ashwinperti
0
Newbie Poster

Sir,

I want to multiply a 2-D array of size 100 by 100

a[100] * b[100];

or a[100][100];

What is the way to multiply the two arrays.

Ashwin Perti

Jump to PostYour first example is ALMOST how to multiply two arrays. A[100] does not exist in an array with 100 elements. you have to create a loop and multiply each array element in array A by the corresponding element in array B. Then the result has to be stored someplace, either …

Jump to PostI don't really understand the question -- but there is no magical way to multiply two arrays. c++ does not support matrix algegra like you would see in a math class. You have to code the loops yourself, unless you want to buy (beg, borrow or seal :cheesy: ) it …

Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster

ashwinperti
0
Newbie Poster

I want to know whether it is possible for the arrays to store the large result that would come out after sop much of maths.

Ashwin Perti

India

Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster

ashwinperti
0
Newbie Poster

But there should be some way.

If we can use pointer in the place of array is it possible

Ashwin Perti

Rashakil Fol
978
Super Senior Demiposter
Team Colleague

You need to be WAAAAAAAY more clear. Multiplication of two integers or floating point approximations is well-defined and everybody knows what you mean. Multiplication of arrays is not.

Do you want to make a multiplication table? That's one interpretation, and since you mentioned a two-dimensional array, that seems possible. However, there are other interpretations, such as dot product, or piecewise product. Or do you wish to perform matrix multiplication?

Unless you better explain what type of multiplication you want to do, you're not going to get a good answer.

Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster

If we can use pointer in the place of array is it possible

Ashwin Perti

You are writng c or c++ program NOT fortran. If you want the compiler to do high-level math then use a fortran compiler, which will PROBABLY do what you want (I don't know and don't care! :) ). When you write c and c++ code there are many things the compiler does NOT do for you -- you have to do them youself or get libraries where someone else did all the work for you.

ashwinperti
0
Newbie Poster

there is situation like this:

main()

{

int a[100],b[100];

int i,j,k,n;

/* we have elements in a[100] = {1,2,3 .. 100}

we have elements in b[100] = {1,2,3 .. 100} */

Multiply the two numbers.

How to do the Multiplication.

}

Answer this.

Ashwin Perti

Rashakil Fol
978
Super Senior Demiposter
Team Colleague

Multiply the two numbers.

This makes no sense. There are two hundred numbers, and 10000 plausible combinations of them.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.