Professional Documents
Culture Documents
Ex 6
Ex 6
No: 6
ExNo:6.a
Selection Sort
Aim:
To read input list numbers using one dimensional array, to sort the list
and display resulting sorted list using one dimensional array.
Algorithm:
Step1: Start
Step2: Read the number of elements present in the list as size
Step3: Read the element present in the list using for loop statement in a single
dimensional array list
Step 4: Select the smallest element in the list and exchange it with the top most
location of unsorted list and then mark that as sorted.
Step5: Repeat step 4 size times.
Step6: Display the final sorted list
Step7: Stop
Program:
#include<stdio.h>
void main ()
{
int i,j,min,temp,list[20],size;
printf(\n Enter no of elements in list);
scanf(%d,&size);
ExNo:6.b
MATRIX ADDITION
Aim:
To read matrices using two dimensional array, add the matrices and
display the resultant matrix using two dimensional array.
Algorithm:
Step1: Start
Step2: Read the number of rows and columns present in matrix one and
matrix two.
Step3: Input matrix one element according to specified number of rows and
columns using two dimensional array and for loop statement.
Step 4: Input matrix two element according to specified number of rows and
columns using two dimensional array and for loop statement.
Step5: Add matrices one and two and store in the resultant matrix.
Step6: Display the resultant matrix.
Step7: Stop
Program:
#include <stdio.h>
void main()
{
int m, n, c, d, first[10][10], second[10][10], sum[10][10];
printf("Enter the number of rows and columns of matrix\n");
scanf("%d%d", &m, &n);
printf("Enter the elements of first matrix\n");