Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Generate an arbitrary 4x4 matrix a. Print out the matrix; b. Write an algorit

ID: 3589146 • Letter: 1

Question

1. Generate an arbitrary 4x4 matrix a. Print out the matrix; b. Write an algorithm to calculate sum of all entries, print your code and result; . Write code to calculate the sum of each row, print your code and result. 2. For an arbitrary array of 10 integers Print the 10 integers; Write code to rearrange these 10 integers so that inside the array the left element is not larger than the right element, print code and the new array; Write code to rearrange these 10 integers so that inside the array the left element is not smaller than the right element, print code and the new array a. b. c.

Explanation / Answer

question 1 : a

Question 1: b

Quetion 1: c

#include <stdio.h>

#define MAXROW 10
#define MAXCOL 10

int main()
{
int matrix[MAXROW][MAXCOL];
int i,j,r,c;
int sum,product;

printf("Enter number of Rows :");
scanf("%d",&r);
printf("Enter number of Cols :");
scanf("%d",&c);

printf(" Enter matrix elements : ");
for(i=0;i< r;i++)
{
for(j=0;j< c;j++)
{
printf("Enter element [%d,%d] : ",i+1,j+1);
scanf("%d",&matrix[i][j]);
}
}
printf(" ");
/*sum of all rows*/
for(i=0;i< r;i++)
{
sum=0; /*initializing sum*/
for(j=0;j< c;j++)
{
printf("%d ",matrix[i][j]); /*print elements*/
sum += matrix[i][j];
}
printf(" SUM : %d",sum);
printf(" "); /*after each row print new line*/
}

}

Question 2 : a

#include<stdio.h>

int main() {

   int i, arr[11], num;

   printf(" Enter no of elements :");

   scanf("%d", &num);

//Reading values into Array

   printf(" Enter the values :");

   for (i = 0; i < num; i++) {

      scanf("%d", &arr[i]);

   }

for (i = 0; i < num; i++) {

      printf(" arr[%d] = %d", i, arr[i]);

   }

return (0);

}

Question 2 : b

question 2: c