c programme for array
DESCRIPTION
C PROGRAMME FOR ARRAYTRANSCRIPT
![Page 1: C PROGRAMME FOR ARRAY](https://reader036.vdocuments.net/reader036/viewer/2022082505/563dbb35550346aa9aab312f/html5/thumbnails/1.jpg)
THIS PROGRAMME IS FOR MATRIX
#include<stdio.h> -#include<conio.h>#include<process.h>void main(){
int mat1[3][3],mat2[3][3], mat3[3][3];int choice,a,b;int i,j,k;clrscr();printf("Press 1 for Addition two Numbers\n");printf("Press 2 for Subtraction two Numbers\n");printf("Press 3 for Multiplication two numbers\n");printf("Press 4 for Division two numbers\n");printf("Press 5 for Remainder two numbers\n");printf("Press 6 for Matrix Addition\n");printf("Press 7 for Matrix Subtraction\n");printf("Press 8 for Matrix MUltiplication\n");printf("Press 9 for EXIT");printf("\nEnter Your Choice\n\n");scanf("%d",&choice);switch(choice){
case 1:printf("Enter Two Numbers for Addition\n");scanf("%d%d",&a,&b);printf("The Addition of two Numbers = %d",(a+b));break;
case 2:printf("Enter Two Numbers for Subtraction\n");scanf("%d%d",&a,&b);printf("The Subtraction of two Numbers = %d",(a-b));break;
case 3:printf("Enter Two Numbers for Multiplication\n");scanf("%d%d",&a,&b);printf("The Multiplication of two Numbers = %d",(a*b));break;
case 4:printf("Enter Two Numbers for Division\n");scanf("%d%d",&a,&b);printf("The Division of two Numbers = %d",(a/b));break;
case 5:printf("Enter Two Numbers for Remainder\n");scanf("%d%d",&a,&b);printf("The Remainder of two Numbers = %d",(a%b));break;
case 6:
![Page 2: C PROGRAMME FOR ARRAY](https://reader036.vdocuments.net/reader036/viewer/2022082505/563dbb35550346aa9aab312f/html5/thumbnails/2.jpg)
printf("\nEnter Elements of the first Matrix\n");for(i=0;i<3;i++){
for(j=0;j<3;j++){
scanf("%d",&mat1[i][j]);}
}printf("Your first Matrix is as follows\n");for(i=0;i<3;i++){
for(j=0;j<3;j++){
printf("%d\t",mat1[i][j]);}printf("\n\n");
}printf("Enter Elements of the SEcond Matrix\n");for(i=0;i<3;i++){
for(j=0;j<3;j++){
scanf("%d",&mat2[i][j]);}
}printf("Your Second Matrix is as follows\n");for(i=0;i<3;i++){
for(j=0;j<3;j++){
printf("%d\t",mat2[i][j]);}printf("\n\n");
}printf("Matrix Addition is as follows:\n");for(i=0;i<3;i++){
for(j=0;j<3;j++){
mat3[i][j] = mat1[i][j] + mat2[i][j];}
}for(i=0;i<3;i++){
for(j=0;j<3;j++){
printf("%d\t",mat3[i][j]);}printf("\n\n");
}break;
case 7:printf("\nEnter Elements of the first Matrix\n");for(i=0;i<3;i++){
for(j=0;j<3;j++)
![Page 3: C PROGRAMME FOR ARRAY](https://reader036.vdocuments.net/reader036/viewer/2022082505/563dbb35550346aa9aab312f/html5/thumbnails/3.jpg)
{scanf("%d",&mat1[i][j]);
}}printf("Your first Matrix is as follows\n");for(i=0;i<3;i++){
for(j=0;j<3;j++){
printf("%d\t",mat1[i][j]);}printf("\n\n");
}printf("Enter Elements of the SEcond Matrix\n");for(i=0;i<3;i++){
for(j=0;j<3;j++){
scanf("%d",&mat2[i][j]);}
}printf("Your Second Matrix is as follows\n");for(i=0;i<3;i++){
for(j=0;j<3;j++){
printf("%d\t",mat2[i][j]);}printf("\n\n");
}printf("Matrix Subtraction is as follows:\n");for(i=0;i<3;i++){
for(j=0;j<3;j++){
mat3[i][j] = mat1[i][j] - mat2[i][j];}
}for(i=0;i<3;i++){
for(j=0;j<3;j++){
printf("%d\t",mat3[i][j]);}printf("\n\n");
}break;
case 8:printf("\nEnter Elements of the first Matrix\n");for(i=0;i<3;i++){
for(j=0;j<3;j++){
scanf("%d",&mat1[i][j]);}
}
![Page 4: C PROGRAMME FOR ARRAY](https://reader036.vdocuments.net/reader036/viewer/2022082505/563dbb35550346aa9aab312f/html5/thumbnails/4.jpg)
printf("Your first Matrix is as follows\n");for(i=0;i<3;i++){
for(j=0;j<3;j++){
printf("%d\t",mat1[i][j]);}printf("\n\n");
}printf("Enter Elements of the Second Matrix\n");for(i=0;i<3;i++){
for(j=0;j<3;j++){
scanf("%d",&mat2[i][j]);}
}printf("Your Second Matrix is as follows\n");for(i=0;i<3;i++){
for(j=0;j<3;j++){
printf("%d\t",mat2[i][j]);}printf("\n\n");
}printf("Matrix Multiplication is as follows:\n");for(i=0;i<3;i++){
for(j=0;j<3;j++){
mat3[i][j]=0;for(k=0;k<3;k++){
mat3[i][j] += mat1[i][k] * mat2[k][j];}
}
}for(i=0;i<3;i++){
for(j=0;j<3;j++){
printf("%d\t",mat3[i][j]);}printf("\n\n");
}break;
case 9: exit(0);default :printf("\nWrong Choice Please try again");
}
getch(); }
![Page 5: C PROGRAMME FOR ARRAY](https://reader036.vdocuments.net/reader036/viewer/2022082505/563dbb35550346aa9aab312f/html5/thumbnails/5.jpg)
RESULT
![Page 6: C PROGRAMME FOR ARRAY](https://reader036.vdocuments.net/reader036/viewer/2022082505/563dbb35550346aa9aab312f/html5/thumbnails/6.jpg)
![Page 7: C PROGRAMME FOR ARRAY](https://reader036.vdocuments.net/reader036/viewer/2022082505/563dbb35550346aa9aab312f/html5/thumbnails/7.jpg)