0% found this document useful (0 votes)
3 views

LAB4

The document contains two C programs. The first program accepts a list of elements to find the maximum and minimum values along with their positions. The second program accepts a matrix, computes its transpose, and checks if the matrix is symmetric.

Uploaded by

nidhaaalshalseer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

LAB4

The document contains two C programs. The first program accepts a list of elements to find the maximum and minimum values along with their positions. The second program accepts a matrix, computes its transpose, and checks if the matrix is symmetric.

Uploaded by

nidhaaalshalseer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Q2.

C PROGRAM TO ACCEPT A LIST OF ELEMENTS AND TO FIND THE


MAXIMUM AND MINIMUM ELEMENTS ALONG WITH THEIR POSITION?

#include<stdio.h>
#include<conio.h>
void main()
{
int arr[10],n,i,big,small,bpos,spos;
clrscr();
printf("enter the number of elements:\n");
scanf("%d",&n);
printf("enter the elements:");
for(i=0;i<n;i++)
{
scanf("%d",& arr[i]);
}
big=arr[0];
small=arr[0];
bpos=1;
spos=1;
for(i=0;i<n;i++)
{
if(big<arr[i])
{
big=arr[i];
bpos=i+1;
}
if(small> arr[i])
{
small=arr[i];
spos=i+1;
}
}
printf("the largest number is %d is at position %d\n",big,bpos);
printf("the smallest number is %d is at position%d",small,spos);
getch();
}
OUTPUT:
Q3. C PROGRAM TO ACCEPT A MATRIX AND FIND THE TRANSPOSE OF THE
MATRIX. ALSO FIND WHETHER THE GIVEN MATRIX IS SYMMETRIC OR
NOT ?

#include<stdio.h>
#include<conio.h>
void main()
{
int a[10][10],m,n,i,j,flag;
clrscr();
flag=0;
printf("enter rows and coloumns:\n");
scanf("%d%d",&m,&n);
printf("enter the matrix element:\n");
for(i=0;i<m;i++)
{
for(i=0;j<n;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("entered matrix is:\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%d\t",a[i][j]);
}
printf("\n");
}
printf("transpose of the matrix is:\n");
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
printf(“%d\t”,a[j][i]);
}
printf(“\n”);
}
if(m!=n)
{
printf("given matrix is not symmetric");
getch();
exit();
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(a[i][j]!=a[j][i])
{
flag=1;
break;
}
}
}
if(flag==0)
printf("\n given matrix is symmetric");
else
printf("\n given matrix is not symmetric");
getch();
}
OUTPUT:

You might also like