473,379 Members | 1,253 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

please help me to fix this code. i am trying to write a program in C that takes in t

And this what i wrote:
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2.  
  3. void printMatrix(int row, int col, float m[row][col]);
  4. float calcEntry(float x[], float y[]);
  5. int main(voide)
  6. {
  7.     int r1,r2,c1,c2,i,j,k;
  8.     float mult[10][10],A[10],B[10];
  9.  
  10.     printf("Enter Row and Column for Matrix1:");
  11.     scanf("%d%d",&r1,&c1);
  12.     printMatrix(r1,c1);
  13.     printf("Emter Row and Column for Matrix2:");
  14.     scanf("%d%d",&r2,&c2);
  15.     printMatrix(r2,c2);
  16.  
  17.     while (c1!=r2) {
  18.         printf("Error! Column of Matrix1 not equal to Rowof Matrix2:\n");
  19.         printf("\n please Enter Column and Row for Matrix1:");
  20.         scanf("%d%d",&r1,&c1);
  21.         printf("Enter Column ans Row for Mtrix2:");
  22.         scanf("%d%d",&r2,&c2);
  23.  
  24.     }
  25.  
  26.     printf("\nEnter elements of matrix 1:\n");
  27.  
  28.     for (i=0; i<r1; ++i)
  29.     for (j=0; j<c1; ++j)
  30. {
  31.     printf("Enter elements A%d%d:", i+1,j+1);
  32.             scanf("%f", &A[i][j]);
  33.         }
  34.     printf("\nEnter elements of matrix 2:\n");
  35.              for(i=0; i<r2; ++i)
  36.              for(j=0; j<c2; ++j)
  37.         {
  38.             printf("Enter elements B%d%d: ",i+1,j+1);
  39.             scanf("%f",&B[i][j]);
  40.         }
  41.     for (i=0; i<r1; ++i)
  42.     for (j=0;j<c2;++j)
  43.     for(k=0;k<c1;++k)
  44.     {
  45.         mult[i][j]+=A[i][k]*B[k][j];
  46.  
  47.     }
  48.     printf("\nOutput Matrix:\n");
  49.     for(i=0;i<r1;++i)
  50.         for(j=0;j<c2;++j)
  51.         {
  52.             printf("%f", mult[i][j]);
  53.             if(j==c2-1)
  54.                 printf("\n\n");
  55.         }
  56.  
  57.     return 0;
  58.  
  59. }
Nov 21 '15 #1
1 2137
zmbd
5,501 Expert Mod 4TB
sahafiza:

Please explain what your issue is with the code.
As you can see, the title isn't a good place to put the actual question do to the size limit.
home > faq > how to post and answer questions on bytes

IF you can post a clear question that explains what it is that you are attempting, contains any error messages (detailed please), and what it is you are attempting to accomplish - it would be my pleasure to merge that post into your original post. :-)


+ We also ask that you use your debugger to step thru the code to determine which line may be causing the issues. It's really not fair to ask our members to do the basic trouble-shooting that could be accomplished by this step. :-)

Also, when posting script, pleas use the [CODE/] format tool in the post toolbar.

:)
Nov 21 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Prashanth Badabagni | last post by:
Hi , I'm Prashanth Badabagni .. I have and idea how a program prints it's own source code .. void main() { FILE *P; char *file,c; strcpy(file,__FILE__); p=fopen(file,"r");
3
by: smith jones | last post by:
Hi all, Can you plz guide me as to how to write data to an excel sheet using C+ + code? Thnks very much for your help!!!
2
by: KLindley | last post by:
I am trying to program an ATtiny13A to count the number of button presses and light up the corresponding LED. I.E. IF the button (PB4) is pressed once, the button in PB1 lights up. The second time...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.