Tuesday, August 14, 2012

Upper Triangle of Square Matrix using C language

#include<conio.h>
#include<stdio.h>
void main()
{
int i,j,a[20][20],k=1,n;
printf("\n Enter the size of square matrix");
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
a[i][j]=k;
k++;
}
}
printf("\n Upper triangle elements:");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(j<i)
{
printf("\n %d",a[i][j]);
}
}
}
getch();
}

No comments:

Post a Comment

DC motor control with Pulse Width Modulation Part 1

DC Motor intro DC motor is a device which converts electrical energy into kinetic energy. It converts the DC power into movement. The typica...