Question

Trying to debug a C program given to me. This is what I was given... //...

Trying to debug a C program given to me. This is what I was given...

// Program to read numeric elements (including decimals) into a 3X3 matrix and display them

#include<stdio.h>

int main(void) {
   int size = 3, Matrix[size][size];
   printf("Enter 9 elements of the matrix:\n")
for (int i = 0, i <=size, i++}
       for (int j = 0, j <= size, i++)
           scan("%c", Matrix1[2][2]);
   diplay(Matrix)


float display(int Matrix1[][], int size) (
   int size = 9;
for (int i = 0, i >= size, i++) {
   for (int j = 0, j >= size, j++) {
       printf("%c, ", Matrix1[i][j]);
printf("\n");
}
return Matrix1;
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include<stdio.h>

void display(int Matrix1[][3], int size);

int main(void) {
    int size = 3, Matrix[3][3], i, j;
    printf("Enter 9 elements of the matrix:\n");
    for (i = 0; i < size; i++)
        for (j = 0; j < size; ++j)
            scanf("%d", &(Matrix[i][j]));
    display(Matrix, size);
    return 0;
}


void display(int Matrix1[][3], int size) {
    int i, j;
    for (i = 0; i < size; i++) {
        for (j = 0; j < size; ++j)
            printf("%d, ", Matrix1[i][j]);
        printf("\n");
    }
}
Add a comment
Know the answer?
Add Answer to:
Trying to debug a C program given to me. This is what I was given... //...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Debug the following matrix program in C: // Program to read integers into a 3X3 matrix...

    Debug the following matrix program in C: // Program to read integers into a 3X3 matrix and display them #include <stdio.h> void display(int Matrix[3][3],int size); int main(void) {         char size;         double Matrix[size][size+1];         printf("Enter 9 elements of the matrix:\n");         int i;         for (i = 0: i <= size: i++)     {       int j = 0;       for (; j <= size++; j++){         scanf("%d", matrix[i--][4])       }     }         Display(Matrix,9);         return 0; void...

  • Could you do that in C language? Here is the code which we got #include <stdio.h>...

    Could you do that in C language? Here is the code which we got #include <stdio.h> #define MAX_SIZE 20 // function definitions void displaySpiral(int matrix[][MAX_SIZE], int size); void displayMatrix(int matrix[][MAX_SIZE], int size); int takeInput(int inputMatrix[][MAX_SIZE]); int main() { int matrix[MAX_SIZE][MAX_SIZE]; int matrixSize = takeInput(matrix); printf("Displaying the whole matrix:\n"); fflush(stdout); displayMatrix(matrix, matrixSize); printf("Now, displaying the matrix in a spiral way:\n"); fflush(stdout); displaySpiral(matrix, matrixSize); return 0; } // already implemented for you int takeInput(int inputMatrix[][MAX_SIZE]) { int size; printf("What is the size...

  • The following program sorts the array of numbers entered by the user and prints out the...

    The following program sorts the array of numbers entered by the user and prints out the elements in descending order. It has many errors. Debug the code and show the output. #include <stdio.h> #define N 4 void desc(float *a, float *b) float tp; tp=a; a=b; b=tp; int main() int i, j, ii, mark[N] ; for (ii==0;ii<N;ii++) printf("Enter the %d th element of your array: \n",ii); scanf("%d", mark[ii]); printf("You have entered the following array: \n"); for (ii=0,ii<N,ii++) printf("%d ", mark[ii]); printf("\n...

  • I'm trying to code a C program so it sorts an array of integer numbers of...

    I'm trying to code a C program so it sorts an array of integer numbers of size n in ascending order. My code is written below but its not working properly, its giving me errors, I think my sort and swap functions aren't done right maybe, please help and fix. It says "undefined reference to "SelectionSort" as an error. But the question asks to not change the PrintArray and Main function. #include <stdio.h> void PrintArray(int size, int array[]) { for...

  • I am trying to add a string command to my code. what am i doing wrong?...

    I am trying to add a string command to my code. what am i doing wrong? #define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include <stdio.h> #include <string.h> #include <math.h> int main(void) {    int i, j;    int rowA, colA, rowB, colB;    int A[10][10], B[10][10];    int sum[10][10];    char str1[10];    printf("This is a matrix calculator\n");    //read in size from user MATRIX A    printf("Enter in matrix A....\n");    printf("\t#row = ");    scanf("%d", &rowA);    printf("\t#col = ");   ...

  • c++ please read all question edit the program to test different random sizes of the array and give me the time in a file will be like random size of the array and next to it the time it took for each...

    c++ please read all question edit the program to test different random sizes of the array and give me the time in a file will be like random size of the array and next to it the time it took for each size Im trying to do time analysis for Quick sort but i keep getting time = 0 also i want edit the program to test different random sizes of the array and give me the time in a...

  • Please help in C: with the following code, i am getting a random 127 printed in...

    Please help in C: with the following code, i am getting a random 127 printed in front of my reverse display of the array. The file i am pulling (data.txt) is: 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 when the reverse prints, it prints: 127 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 not sure why...please...

  • Please I need help in C language, I am trying to modify the code per the...

    Please I need help in C language, I am trying to modify the code per the below instructions, but I am getting errors. Can't fgure it out. The attempted code modification and data file is privided below, after the instructions. Thank you. Instructions:                  1.      First, add a function named printMsg that displays a message, a greeting, or an introduction to the program for the user. Add a statement that calls that function from the main function when your program starts....

  • #include <stdio.h> #include <sys/time.h> #define DEBUG 1 //Constant is defined for true int main() { struct timeval start,end; //to store time of starting and ending of program //if state...

    #include <stdio.h> #include <sys/time.h> #define DEBUG 1 //Constant is defined for true int main() { struct timeval start,end; //to store time of starting and ending of program //if statement is added if(DEBUG){ gettimeofday(&start,0); } printf("Time in microsecond for every second: \n"); //output for(int i=0;i<100;i++) //outer loop to run 100 times { struct timeval loopstart,loopend; //to store time of starting and ending of loop //if statement added if(DEBUG){ gettimeofday(&loopstart,0); //measuring time at start of loop } for(int j=0;j<1000000;j++); //outer loop to...

  • I need the programming to be in language C. I am using a program called Zybook...

    I need the programming to be in language C. I am using a program called Zybook Prompt: Write a statement that outputs variable numObjects. End with a newline. Given: #include <stdio.h> int main(void) { int numObjects; scanf("%d", &numObjects); return 0; } What I did so far. I am not sure if its right tho? #include <stdio.h> int main(void) { int numObjects; scanf("%d", &numObjects); printf(" num Objects is "); printf("%d\n", userAge); return 0; }

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT