#include<stdio.h> main() { int a[5][5],b[5][5],c[5][5],i,j,m,n; printf("\n Enter the Dimension of the Matrix:\n"); scanf("%d%d",&m,&n); printf("\nEnter the Elements of the first matix:"); for(i=0;i<m;i++) { for(j=0;j<n;j++) { scanf("%d",(*(a+i)+j)); } } printf("\nEnter the elements of the second matrix:\n"); for(i=0;i<m;i++) { for(j=0;j<n;j++) { scanf("%d",(*(b+i)+j)); } } for(i=0;i<m;i++) { for(j=0;j<n;j++) { *(*(c+i)+j)=*(*(a+i)+j)+ *(*(b+i)+j); } } printf("\nResultantMatrix:\n"); for(i=0;i<m;i++) { for(j=0;j<n;j++) { printf("%5d",*(*(c+i)+j)); } printf("\n"); } getch(); } Output: Enter the Dimension of the Matrix: 2 2 Enter the Elements of the first matix: 1 2 3 4 Enter the elements of the second matrix: 9 8 7 6 ResultantMatrix:
Program to input the name of the branches, total sales of the company into an array of structures, display the branch name and sales of branch who had highest sales. #include<stdio.h> struct branch { char name[25]; long sale; }; main() { struct branch b[100]; int n,i,m; long max; clrscr(); printf("\nEnter the no. of Branches"); scanf("%d",&n); for(i=0;i<n;i++) { printf("\nEnter the details of branch %d",i+1); printf("\nEnter the branch name\n"); scanf("%s",b[i].name); printf("\nEnter the total sales:\n"); scanf("%ld",&b[i].sale); } max=b[0].sale; m=0; for(i=1;i<n;i++) { if(b[i].sale>max) { max=b[i].sale; m=i; } printf("\nBranch with highest Sales:"); printf("\nName:%s",b[i].name); printf("\nSales: %d\n",b[i].sale); } getch(); }