Wednesday, September 29, 2010

Sum of upper and lower trangular matrix

/*************************************
* Program TO Find The Sum *
* Of Upper And Lower *
* Trangular Matrix And Find *
* Which Sum Is Greater *
*************************************/
#include
#include
void main()
{
int i,j,row,col,upp,low,el[10][10];
clrscr();
upp=low=0;
printf("enter the size of a square matrix");
scanf("%d%d",&row,&col);
printf("Enter the elements");
for(i=0;i>>>>\n");
for(i=0;ii)
upp=upp+el[i][j];

else if(jlow)
printf("\nSum of Upper Trangular matrix is more");
else if(upp
printf("\nSum of lower trangular matrix is more");
else
printf("\nSum is equal");
getch();
}

A matrix is Symmetric or not

/****************************************
* Program to Chech Wheather *
* a matrix is Symmetric or *
* Not *
****************************************/
#include
#include
void main()
{
  int i,j,row,col,ele[10][10],ele2[10][10],val=0;
  clrscr();
  printf("enter the size of a square matrix**>");
  scanf("%d%d",&row,&col);
  printf("enter %d Elements",row*col);
for(i=0;i
{
for(j=0;j
{
scanf("%d",&ele[i][j]);
}
printf("\n");
}
for(i=0;i
{
for(j=0;j
{
ele2[j][i]=ele[i][j];
}
}
for(i=0;i
{
for(j=0;j
{
if(ele[i][j]==ele[j][i])
{
val++;
}
else
{
val=0;
break;
}
}
}
for(i=0;i
{
for(j=0;j
{
printf("\t%d",ele[i][j]);
}
printf("\n");
}
if(val==(row*col))
{
printf("It's a symmetric matrix");
}
else
{
printf("It's not a symmetric matrix");
}
getch();
}

Decimal to other Number System

/*******************************************
* Program To Convert *
* Dec---binary *
* Dec---Octal *
* Dec---Hexadecimal *
*******************************************/
#include
#include
void main()
{
int bin[50],dec,num,i,len=0,oct[20],val,hex[30];
clrscr();
printf("Enter any Decimal Number");
scanf("%d",&dec);
num=dec;
while(dec>0)
{
dec=dec/2;
len++;
}
printf("%d\n",len);
dec=num;
for(i=0;i0)
{
oct[i]=dec%8;
dec=dec/8;
i++;
}


dec=num;
i--;
printf("value of Decimal To octal>>>>");
while(i>=0)
{
printf("%d",oct[i]);
i--;
}


printf("\n Decimal TO Binary>>>>");
for(i=len-1;i>=0;i--)
{
printf("%d",bin[i]);
}


dec=num;
i=0;
while(dec>0)
{
hex[i]=dec%16;
dec=dec/16;
if(hex[i]>9)
{
val=hex[i]-9;
hex[i]=64+val;
}
i++;
}


i--;
printf("\n Value of Decimal to hexadecimal conversion is");
while(i>=0)
{
if(hex[i]<=9)
printf("%d",hex[i]);
else
printf("%c",hex[i]);
i--;
}
getch();
}

Series Of 9

/* program to print output as ***
*      9 *
*    89 *
*  789 *
* 6789 *
*********************************/
#include
#include
void main()
{
int i,j;
unsigned int num;
clrscr();
printf("enter any positive integer number less thna or equal to 9");
scanf("%d",&num);
for(i=num;i>=1;i--)
{
for(j=1;j<=num;j++)
{
if(j
printf(" ");
else
printf("%d",j);
}
printf("\n");
}
getch();
}