Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

How do I replace symbols in a matrix?

–1 vote
asked Mar 26, 2020 by Pedro Rendon (110 points)
***My Code in C***

#include<stdio.h>

int main() {

    int i = 0;
    int j = 0;
    int h;
    char x = '+';
    char y = '%';
    int matrix[7][7];
    
    for (i = 0; i < 7; i++) {
        printf("\n");
        
       
        
        for (j = 0; j < 7; j++) {
            printf("\t%c", x);
        }

       
        }

        return 0;
    }

***End***

I need to replace the symbols under the blue line.

Image of which symbols I am trying to replace: https://imgur.com/a/wPtvqc1

(ignore the old old code in the picture)

Thank you.

1 Answer

+2 votes
answered Apr 22, 2021 by subashini (190 points)

#include<stdio.h>
int main() 
{
    int h;
    char x = '+';
    char y = '%';
    int matrix[7][7];
    for (int i = 0; i < 7; i++) 
    {
        printf("\n");
        for (int j = 0; j < 7; j++) 
        {
            if(i==j)
            printf("\t%c", y);
            else
            printf("\t%c", x);
        }
    }
    return 0;
}

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...