Lab Programmes
Lab Programmes
Lab Programmes
Exercise – 6
6. A
Source code:
#include <stdio.h>
void main()
{
int arr1[50][50],brr1[50][50],crr1[50][50],i,j,k,r1,c1,r2,c2,sum=0;
VIEW Page 29
ROLL No: PROGRAMMING FOR PROBLEM SOLVING USING C
for(j=0;j<c1;j++)
printf("%d\t",arr1[i][j]);
}
VIEW Page 30
ROLL No: PROGRAMMING FOR PROBLEM SOLVING USING C
6.b
Aim: Write a program in C to find transpose of a given matrix.
Source code:
#include <stdio.h>
void main()
{
int arr1[50][50],brr1[50][50],i,j,k=0,r,c;
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
brr1[j][i]=arr1[i][j];
}
}
VIEW Page 32
ROLL No: PROGRAMMING FOR PROBLEM SOLVING USING C
for(j=0;j<r;j++){
printf("%d\t",brr1[i][j]);
}
}
printf("\n\n");
}
VIEW Page 33
ROLL No: PROGRAMMING FOR PROBLEM SOLVING USING C
Exercise – 7
7. A
Aim: Write a program in C to search an element in a row wise and column wise sorted
matrix.
Source code:
#include <stdio.h>
int i = 0, j = n-1;
if ( arr2D[i][j] == x )
printf("\nThe element Found at the position in the matrix is: %d, %d", i, j);
return 1;
if ( arr2D[i][j] < x )
j--;
else
i++;
return 0;
int main()
VIEW Page 35
ROLL No: PROGRAMMING FOR PROBLEM SOLVING USING C
};
int i,j,v;
v=37;
for (j=0;j<4;j++)
printf("\n");
//
searchElement(arr2D, 4, v);
return 0;
VIEW Page 36