//WAP to get sum of elements of first row of a matrix of order 'mxn'.
#include<stdio.h>
#include<conio.h>
void main()
{
int matrics_1[100][100];
int i,j,sum=0;
int total_row,total_col;
printf("enter total number of rows(m)\n");
scanf("'%d",&total_row);
printf("'enter total columns(n)\n");;
scanf("%d",&total__col);
printf("enter elements of matrix\n");
for(i=0;i<=0;i++) // for rows
{
for(j=0;j<total_col;j++) // for columns
{
scanf("%d",&matrics_1[i][j]);
sum=sum+matrics_1[i][j];
}
}
printf("sum=%d",sum);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int matrics_1[100][100];
int i,j,sum=0;
int total_row,total_col;
printf("enter total number of rows(m)\n");
scanf("'%d",&total_row);
printf("'enter total columns(n)\n");;
scanf("%d",&total__col);
printf("enter elements of matrix\n");
for(i=0;i<=0;i++) // for rows
{
for(j=0;j<total_col;j++) // for columns
{
scanf("%d",&matrics_1[i][j]);
sum=sum+matrics_1[i][j];
}
}
printf("sum=%d",sum);
getch();
}
No comments:
Post a Comment