FYBCA ( Sem–II) Assignment No.4 Array program.(solved assignment)



Student Name: Shinde Sachin Dadarao.                                      Roll No:149
Program Name: Write a program to input an array and display it in reverse order.

#include<stdio.h>
#include<conio.h>
void main()
{
int a[5];
int i;

clrscr();

printf("\n enter the array element-");

for(i=0;i<5;i++)
 {
 scanf("\n %d",&a[i]);
 }

printf("\n the array element are");

for(i=4;i>=0;i--)
 {
 printf("\n %d",a[i]);
 }

getch();
}
/* Output
enter the array element-7 14 21 28 35
the array element are
35
28
21
14
7 */









Student Name: Shinde Sachin Dadarao.                                      Roll No:149
Program Name: Write a program to input an array and display it in ascending order.

#include<stdio.h>
#include<conio.h>
void main()
{
int a[5];
int i,j,n,temp;
clrscr();
printf("\n enter the limit of array-");
scanf("\n %d",&n);
printf("\n enter the array element-");
for(i=0;i<n;i++)
 {
 scanf("\n %d",&a[i]);
 }
for(i=0;i<n;i++)
 {
 for(j=i+1;j<n;j++)
  {
  if(a[i]>a[j])
   {
   temp=a[i];
   a[i]=a[j];
   a[j]=temp;
   }
  }
 }
printf("\n ascending order element are-");
 for(i=0;i<n;i++)
  {
  printf("\n %d",a[i]);
  }
getch();
}
/* Output
Enter the limit of array-5
Enter the array element-24 95 12 7 53
ascending order element are-
7
12
24
53
95  */
Student Name: Shinde Sachin Dadarao.                          Roll No:149
Program Name: Write a program to input an array and find minimum number from given                             array.

#include<stdio.h>
#include<conio.h>
void main()
{
int a[5];
int i,n,min;
clrscr();

printf("\n enter the limit of array-");
scanf("\n %d",&n);

printf("\n enter the limit of array-");

for(i=0;i<n;i++)
 {
 scanf("\n %d",&a[i]);
 }

 min=a[0];

for(i=1;i<n;i++)
 {
 if(a[i]<min)
  {
  min=a[i];
  }
 }

printf("\n the smallest element is %d",min);
getch();
}
/* Output
Enter the limit of array-5
Enter the limit of array-25 48 53 10 49

The smallest element is 10 */







Student Name: Shinde Sachin Dadarao.                                      Roll No:149
Program Name: Write a program to input an array and find maximum number from given                           array.

#include<stdio.h>
#include<conio.h>
void main()
{
int a[5];
int i,n,max;
clrscr();
printf("\n enter the limit of array-");
scanf("\n %d",&n);
printf("\n enter array element-");
for(i=0;i<n;i++)
 {
 scanf("\n %d",&a[i]);
 }
 max=a[0];
for(i=1;i<n;i++)
 {
 if(a[i]>max)
  {
  max=a[i];
  }
 }
printf("\n the largest element is %d",max);
getch();
}
/* Output
Enter the limit of array-5
Enter array element- 10 35 49 25 5

The largest element is 49 */













Student Name: Shinde Sachin Dadarao.                          Roll No:149
Program Name: Write a program to input two m*n matrices and display it’s addition.

#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],b[3][3];
int i,j,add[3][3];
clrscr();

printf("\n enter first array-");

for(i=0;i<3;i++)
 {
 for(j=0;j<3;j++)
  {
  scanf("\n %d", &a[i][j]);
  }
 }

printf("\n enter second array-");

for(i=0;i<3;i++)
 {
 for(j=0;j<3;j++)
  {
  scanf("\n %d",&b[i][j]);
  }
 }

for(i=0;i<3;i++)
 {
 for(j=0;j<3;j++)
  {
  add[i][j]=a[i][j]+b[i][j];
  }
 }

printf("\n the addition matrix are-");

for(i=0;i<3;i++)
 {
 for(j=0;j<3;j++)
  {
  printf("\t %d",add[i][j]);
  }
 printf("\n");
}
getch();
}
/* Output
Enter first array-      5 3  1
                                    1 2 27
                                    4 3  1

Enter second array-   0  3   9
                                     3  2  26
                                     8 11 20

The addition matrix are- 5  6  10
                                          4   4  53
                                         12 14  21  */






























Student Name: Shinde Sachin Dadarao.                                      Roll No:149
Program Name: Write a program to input two m*n matrices and display transpose of                                               matrix.

#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],trans[3][3];
int i,j;
clrscr();
printf("\n enter the array element-");
for(i=0;i<3;i++)
 {
 for(j=0;j<3;j++)
  {
  scanf("\n %d", &a[i][j]);
  }
 }
for(i=0;i<3;i++)
 {
 for(j=0;j<3;j++)
  {
  trans[i][j]=a[j][i];
  }
 }
printf("\n the transpose of matrix is-");
for(i=0;i<3;i++)
 {
 for(j=0;j<3;j++)
  {
  printf("\t %d",trans[i][j]);
  }
 printf("\n");
}
getch();
}
/* Output
Enter the array element- 2  3  5
                                           7  9  11
                                         21 53 20

The transpose of matrix is-2 7 21
                                              3 9 53
                                              5 11 20  */

Student Name: Shinde Sachin Dadarao.                                      Roll No:149
Program Name: Write a program to input two m*n matrices and display its multiplication.

#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],b[3][3],multi[3][3];
int i,j,k;

clrscr();

printf("\n enter first matrix-");

for(i=0;i<3;i++)
 {
 for(j=0;j<3;j++)
  {
  scanf("\n %d", &a[i][j]);
  }
 }

printf("\n enter second matrix-");

for(i=0;i<3;i++)
 {
 for(j=0;j<3;j++)
  {
  scanf("\n %d",&b[i][j]);
  }
 }

for(i=0;i<3;i++)
 {
 for(j=0;j<3;j++)
  {
 
 multi[i][j]=0;
 
 for(k=0;k<3;k++)
  {
  multi[i][j]=multi[i][j]+(a[i][k]*b[k][j]);
  }
 }
}

printf("\n the matrix multiplication is-");

for(i=0;i<3;i++)
 {
 for(j=0;j<3;j++)
  {
  printf("\t %d",multi[i][j]);
  }
 printf("\n");
}

getch();
}

/* Output
Enter first matrix-  1 2 3
                                  4 5 6
                                  7 8 9

Enter second matrix-  1 2 3
                                      4 5 6
                                      7 8 9

The matrix multiplication is-30    36    42
                                                 66    81    96
                                                 102  126  150  */