//FROM LEFT TO RIGHT
#include
#include
void main()
{
int a[5][5],r,c,i,j,S=0;
int sum1=0,sum2=0;
clrscr();
printf("\n\nENTERED THE SIZE OF ROW=");
scanf("%d",&r);
printf("\n\nENTERED THE SIZE OF COLOUMN=");
scanf("%d",&c);
printf("\n\nENTERED THE ELEMENTS IN AN 2D ARRAY=");
for(i=0;i< r;i++)
{
for(j=0;j< c;j++)
scanf("%d",&a[i][j]);
}
printf("\n\n\n");
printf("\n\nENTERED MATRIX IS:\n");
for(i=0;i< r;i++)
{
for(j=0;j< c;j++)
{
printf("%d",a[i][j]);
printf(" ");
}
printf("\n\n");
}
S=r;
for(i=0;i< r;i++)
{
for(j=0;j< c;j++)
if(a[i]==a[j])
sum1+=a[i][j];
}
printf("\n\nDIAGNAL SUM FROM LEFT TO RIGHT=%d",sum1);
getch();
}
/*********************************************************************
OUTPUT
*********************************************************************
ENTERED THE SIZE OF ROW=3
ENTERED THE SIZE OF COLOUMN=3
ENTERED THE ELEMENTS IN AN 2D ARRAY=1
2
3
4
5
6
7
8
9
ENTERED MATRIX IS:
1 2 3
4 5 6
7 8 9
DIAGNAL SUM FROM LEFT TO RIGHT=15
*/
plz make your all program in iostream.h file ,,including this one...
ReplyDelete