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 display(float Matrix[3][3], int size) {
for (int i = 0, i > size: i++) {
for (int j = size: j >= 0;j--)
{
printf("#x, ", *matrix[j++][i]):
}
printf("\n");
}
}
}
C CODE:
//it is also work for nxn matrix
#include<stdio.h>
void display(int size,int matrix[size][size]) //first argument
should be size
//then matrix[size][size] is
valid or else it promt as error size is not defined
{
// before using i,j you should be deleare them then
you use
int i,j;
// this loop for rows 0th row to size the condition is
i=0 to i<size
printf("The matrix is\n");
for( i = 0;i<size;i++)
{
//this loop for column 0th column
to size the condition is j=0 to j<size
for(j = 0;j<size;j++)
{
// it is for
printing the row
printf("%d
",matrix[i][j]);
}
//it is for differencating the rows
with newline
printf("\n");
}
}
main()
{
int size,i,j;
scanf("%d",&size); // reading size of the matrix
from user
int Matrix[size][size];
printf("Enter %d elements of the matrix
:\n",size*size); // if size if 3 then 9 element if size if 2 then 4
elements
// this loop is for reading i'th row
for(i = 0;i<size;i++)
{
// this loop is for ith row j'the
column value
for(j = 0;j<size;j++)
{
// reading
values in to matrix
scanf("%d",&Matrix[i][j]);
}
}
//calling display function with passing size and
matrix as arguments
display(size,Matrix);
}


Any Queries Feel Free To Comment
Thank You
Debug the following matrix program in C: // Program to read integers into a 3X3 matrix...
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) ( ...
Write a C Program that inputs an array of integers from the user along-with the length of array. The program then prints out the array of integers in reverse. (You do not need to change (re-assign) the elements in the array, only print the array in reverse.) The program uses a function call with array passed as call by reference. Part of the Program has been given here. You need to complete the Program by writing the function. #include<stdio.h> void...
Please help with this coding 1.You need to dynamically allocate memory to read into a number of elements. At first, you need to determine how many numbers (here, ‘n’) to be read. Next, you need to dynamically allocate memory for ‘n’ integers. As you see,‘x’ is an integer pointer which needs to dynamically allocate memory to read ‘n’integers into it fromthekeyboard. 2 Read nintegers into the allocated block using scanf. 3. Complete the printArrayfunction to display ‘n’ integers. void printArray(int...
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 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...
C program
Classwork_3.3: Correct the program below that will read two numbers: number of drinks and number of sandwiches, and display the total bill calculated as: Total bill = Number of Drinks X 5.50 + Number of Sandwiches X 10.00 Answer the questions below. C-Program with error: Write the correct program here: #include<stdio.h> int main (void) floats numberofDrinks, numberofSandwiches; float totalBilling: printf("Enter number of Drinks \n"); scanf("%d",&numberofdrinks); printf("Enter number of Sandwiches\n") scanf("%f",&numberofSandwiches); totalbilling = numberofDrinks *5.50 + numberofsandwiches/10.00; printf("Total bill...
A)Correct this code and explain what was corrected // C code - For Loop / Array Population // This program will populate integers into an array, and then display those integers. // Developer: Johnson, William CMIS102 // Date: Mar 4, 2020 // Global constants #define INTLIMIT 10 #include <stdio.h> // This function will handle printing my name, class/section number, and the date void printStudentData() { char fullName[19] = "William J. Johnson"; char classNumber[9] = "CMIS 102"; char sectionNumber[5] = "4020";...
C program help: Write a C program that uses three functions to perform the following tasks: – The first function should read the price of an item sold at a grocery store together with the quantity from the user and return all the values to main(). example: #include void getInput(int *pNum1, int *pNum2); // note: *pNum1 & *pNum2 are pointers to ints int main () { int numDucks,numCats; getInput(&numDucks, &numCats); // passing addresses of num1 & num2 to...
9. The purpose of the following program is to generate 10 random integers, store them in an array, and then store in the freq frequency array, the number of occurrences of each number from 0 to 9. Can you find any errors in the program? If yes, correct them. #include <stdio.h> #include <stdlib.h> #include <time.h> #define SIZE 10 int main(void) int i, num, arr[SIZE], freq[SIZE]; srand (time (NULL)); arr[1] rand(); SIZE; for(i i 〈 i++) num arr[i]; freq[num]++; printf("InNumber occurrences...
OPERATING SYSTWM
Question 31 What is the output of this C program? #include #include void main() int mptr, *cptr mptr = (int*)malloc(sizeof(int)); printf("%d", "mptr); cptr = (int)calloc(sizeof(int),1); printf("%d","cptr); garbage 0 000 O garbage segmentation fault Question 8 1 pts If this program "Hello" is run from the command line as "Hello 12 3" what is the output? (char '1'is ascii value 49. char '2' is ascii value 50 char'3' is ascii value 51): #include<stdio.h> int main (int argc, char*argv[]) int...