Error: subscripted value is neither array nor Pointer nor vector

Asked

Viewed 96 times

0

What am I doing wrong in this code of mine to be making this mistake?

Statement: Given the Matrix A = {{10, 30, 50}, {5, 15, 25}, {2, 5, 9}} and the Matrix B= {{5, 35, 70}, {1, 25, 30}, {1, 4, 7}}, do a program that manages Matrix C containing the highest values of each position. Show Matrix C.

#include <stdio.h>

int main ()
{
    int matriz_A = {{10, 30, 50}, {5, 15, 25}, {2, 5, 9}}, matriz_B = {{5, 35, 70}, {1, 25, 30}, {1, 4, 7}}, matriz_C = 0;

    for (int i = 0; i <= 3; i++)
    {
        for (int j = 0; j <= 3; j++)
        {
            if (matriz_A[i][j] > matriz_B[i][j])
            {
                matriz_C[i][j] = matriz_A[i][j];
            }
            
            if (matriz_A[i][j] < matriz_B[i][j])
            {
                matriz_C[i][j] = matriz_B[i][j];
            }
        }
    }

    printf("%d", matriz_C);


    return 0;
}
  • matriz_C was declared as a int and worth zero. So it’s going to be worth how much? Zero. You can’t use indexes in a section like this. matriz_C must be declared equal to the other two...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.