Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4272774
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:37:23+00:00 2026-05-21T07:37:23+00:00

I am trying to multiply two 3×3 matrices. The first 2 numbers in the

  • 0

I am trying to multiply two 3×3 matrices. The first 2 numbers in the first
and second row are the only correct answer. What am I doing
wrong? Is the stuff I need declared in mult_matrices?

#include <stdio.h>

void mult_matrices(int a[][3], int b[][3], int result[][3]);
void print_matrix(int a[][3]);

int main()
{
    int p[3][3] = {{1, 2, 3},{4, 5, 6}, {7, 8, 9}};
    int q[3][3] = {{10, 11, 12}, {13, 14, 15}, {16, 17, 18}};
    int r[3][3];

    mult_matrices(p, q, r);
    print_matrix(r);
}

void mult_matrices(int a[][3], int b[][3], int result[][3])
{
    int i, j, k;
    for(i = 0; i < 3; i++)
    {
            for(j = 0; j < 3; j++)
            {
                    for(k = 0; k < 3; k++)
                    {
                            result[i][j] +=  a[i][k] *  b[k][j];
                    }
            }
    }
}

void print_matrix(int a[][3])
{
    int i, j;
    for (i = 0; i < 3; i++)
    {
            for(j = 0; j < 3; j++)
            {
                    printf("%d\t", a[i][j]);
            }
            printf("\n");
    }
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T07:37:23+00:00Added an answer on May 21, 2026 at 7:37 am

    Looks like you’re not initializing your result matrix.

    i.e. Change:

    int r[3][3];
    

    to

    int r[3][3] ={{0,0,0},{0,0,0},{0,0,0}};
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to multiply two strings, but I am getting the wrong answer.
I'm trying to multiply two matrices using vecLibs' cblas: #include <stdlib.h> #include <string.h> #include
I am new to Xcode, i am just trying to multiply the two numbers
I am trying to add/sub/multiply two complex numbers. Terminal said there is a SyntaxError
I am new to Parallel Programming. I am trying to multiply two matrices. I
Im trying to multiply two 16 bit numbers with the following NASM codes: mov
I'm trying to multiply two matrices stored inside 1d arrays. I'm using this function,
I'm trying to multiply two arrays without using numpy. But, I receive an error
I am trying to overload the * operator in order to multiply two objects
I am trying to add up two numbers in PowerShell. I have the input

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.