This article will show how
to find boundary elements and higher and lower level elements of a matrix or a two
dimensional array with C and C++ program. The following program will first take
user inputs to build a two dimensional array or a matrix and then show the
matrix, the boundary elements and the sum of the boundary elements, diagonal
elements and its sum. Here, for loop is used to set and retrieve array
elements.
Programming code to find boundary elements and higher and lower level elements of a matrix.
Programming code to find boundary elements and higher and lower level elements of a matrix.
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5][5],m,n,sum=0;
printf("Enter
row :");
scanf("%d",&m);
printf("Enter coloum :");
scanf("%d",&n);
printf("Enter matrix element
:\n");
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
printf("a[%d][%d]=",i,j);
scanf("%d",&a[i][j]);
}
}
printf("\nMatrix is : \n");
for(i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
printf("%d\t",a[i][j]);
}
printf("\n");
}
printf("\nBoundary element :");
for(i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
if((i*j==0)||(i==m-1)||(j==n-1))
{
printf("%d ",a[i][j]);
sum=sum+a[i][j];
}
}
}
printf("\nSum of boundary element is
: %d",sum);
printf("\nHigher level : ");
sum=0;
for(i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
if(i==j)
{
printf("\t%d",a[i][j]);
sum=sum+a[i][j];
}
}
}
printf("\nSum of higher level =
%d",sum);
printf("\nLower lavel : ");
sum=0;
i=m;
for(int j=0;j<n;j++)
{
i=i-1;
printf("\t%d",a[i][j]);
sum=sum+a[i][j];
}
printf("\nSum of lower level =
%d",sum);
}
Output
5 comments:
This is very helpful program thanks for sharing Exam Notes
The Every Other Day Diet doesn't use calorie counting. By eliminating everything but water I realized that I was reducing 1000s of calories that I get from tea and soft drinks inside a given week phen375 ingredients it also contains gaba, a calming neurotransmitter and lots of other useful ingredients. If you wanted to shed and you didn't, subtract an additional 250 calories from your everyday total for one more week. Losing weight occurs when you burn more calories than you take in http://www.phen375factsheet.com make certain to choose vegetables and fruit that fresh, it will be as being the main reason that the fresher due to the fact are, the fewer calories each goes. Exercising an excessive amount of, fat loss crash diet or starting any regimen without checking with your doctor first can put your quality of life in danger and result in injuries [url=http://www.phen375factsheet.com/]phen375[/url] in case study, people who didn't have a very weight problem slept, normally, a long time more per week than individuals who were experiencing weight issues.
I am learning CSS & HTML, they are fairly easy, I am also interested in learning Java, but I will look at C++ interesting blog, also look at this website that we are promoting.
www.spiritlessons.com
I read this post completely on the topic of the resemblance of hottest and previous technologies, it's awesome article.
my page - graduate certificates online
My programmer is trying to convince me to move to .
net from PHP. I have always disliked the idea because of the expenses.
But he's tryiong none the less. I've been using WordPress on several websites for
about a year and am concerned about switching to another platform.
I have heard excellent things about blogengine.net. Is there a way I can import all my wordpress content into it?
Any kind of help would be greatly appreciated!
Have a look at my blog post: best diet
Post a Comment