Forum     

Go Back   Digit Technology Discussion Forum > Portables, Peripherals and Electronics > QnA (read only)
Register FAQ Calendar Mark Forums Read

QnA (read only) Mods please help transfer the contents of this forum to proper sections. :)


 
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-10-2007, 08:08 PM   #1 (permalink)
Apprentice
 
vinit suri's Avatar
 
Join Date: Feb 2007
Posts: 87
Default thread closed


thread closed
__________________
IF THIS HELPS PLEASE CLICK THE BALANCE UNDER MY ID............:wink: 8-)

Last edited by vinit suri; 06-10-2007 at 09:16 PM. Reason: thread closed
vinit suri is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 03-10-2007, 09:19 PM   #2 (permalink)
Commander in Chief
 
QwertyManiac's Avatar
 
Join Date: Jul 2005
Posts: 6,658
Default Re: help wid c program 2 multiply 2 matrices....

You missed using Ampersands while taking array inputs.

The below program is right and executes well for two 3x3 matrices filled with '3'. The output being a matrix with every element as 3 cubed (27).

Code:
#include<stdio.h>
int main()
{
int a[3][3],b[3][3],r[3][3],i,j,c,d,s;
i=0;
j=0;
c=0;
d=0;
s=0;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("enter 1 :");
scanf("%d",&a[i][j]);
}
}
i=0;
j=0;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{

printf("enter 2 :");
scanf("%d",&b[i][j]);
}
}
s=0;
for(c=0;c<3;c++)
{
for(d=0;d<3;d++)
{
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
s=s+(a[i][j]*b[j][i]);
}
r[c][d]=s;
s=0;
}
}

}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%d\t",r[i][j] );
}
printf("\n");
}

}
I haven't altered any logic, though I guess you sure can shorten the code a lot.

Check this thread too.
QwertyManiac is offline  
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Rumors multiply of 'Google Phone' launch Gigacore Technology News 6 01-09-2007 08:52 PM
How to use a FTP program? Anindya Software Q&A 1 22-03-2007 12:52 AM
calculating the time, larger matrices! help pls. legolas QnA (read only) 2 13-10-2005 09:14 AM
new program in 'close program menu' list and more....... vishakadatta QnA (read only) 2 12-04-2005 11:33 PM
C++ Program Q. shwetanshu Programming 5 09-02-2005 01:50 PM

 
Latest Threads
- by ico
- by Charan
- by Piyush
- by icebags
- by clinton

Advertisement




All times are GMT +5.5. The time now is 12:30 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2