1 D ARRAY:
1.To find the largest element in an array. 2. to search a particular item in an array. 3. bubble sort. 4. to find the largest and second largest element in an array. 5. insert an item at a particular location. 6 delete an item from a particular location.
2 D ARRAY: 1.Multiplication of two matrics
#include<stdio.h> #include<conio.h> void main( ) { Int a[3][3],b[3][3],c[3][3],i,j,k; printf(\n enter the elements of first matrics:\n) for(i=0;i<3;i++) { for( j= 0;j<3;j++) { scanf(%d,&a[i][j]); } } printf(\n enter the elements of second matrics:\n) for(i=0;i<3;i++) { for( j= 0;j<3;j++) { scanf(%d,&b[i][j]); } } for(i=0;i<3;i++) {
for( j= 0;j<3;j++) { c[i][j]=0; for(k=0;k<3;k++) { C[i][j] = c[i][j]+a[i][k]*b[k][j]; } } } printf(\n Multiplication of two matrics is:\n) for(i=0;i<3;i++) { for( j= 0;j<3;j++) { printf( %d,c[i][j]); } printf(\n); } getch(); }
2. Write a program to print the sum of diagonal elements of 2D array.
#include<stdio.h> #include<conio.h> void main( ) { Int a[3][3],i,j,sum=0; printf(\n enter the elements of matrics:\n) for(i=0;i<3;i++) { for( j= 0;j<3;j++) { scanf(%d,&a[i][j]); } } for(i=0;i<3;i++) { for( j= 0;j<3;j++) {
if( i == j || i+j=2) { sum = sum+a[i][j]; } } } printf(\n Sum of diagonal elements is %d,sum); getch(); }
3. Write a program to increment each diagonal elements of 2D array by 1.
#include<stdio.h> #include<conio.h> void main( ) { Int a[3][3],i,j; printf(\n enter the elements of matrics:\n) for(i=0;i<3;i++) { for( j= 0;j<3;j++) { scanf(%d,&a[i][j]); } } for(i=0;i<3;i++) { for( j= 0;j<3;j++) { if( i == j || i+j=2) { a[i][j] = a[i][j]+1; } } } printf(\n matrics after increment is :\n);
for(i=0;i<3;i++) { for( j= 0;j<3;j++) { printf( %d,&a[i][j]); } printf(\n); } getch(); }
4. Write a program to replacing each diagonal elements of 2D array by 0.
#include<stdio.h> #include<conio.h> void main( ) { Int a[3][3],i,j; printf(\n enter the elements of matrics:\n) for(i=0;i<3;i++) { for( j= 0;j<3;j++) { scanf(%d,&a[i][j]); } } for(i=0;i<3;i++) { for( j= 0;j<3;j++) { if( i == j || i+j=2) { a[i][j] = 0; } } }
printf(\n matrics after placing 0 is :\n); for(i=0;i<3;i++) { for( j= 0;j<3;j++) { printf( %d,a[i][j]); } printf(\n); } getch(); }
SUM OF DIGITS OF A NUMBER. CHECK A NUMBER IS PALINDROME OR NOT