i've tried to sum and display two right angle triangles

#include<iostream.h>
#include<conio.h>
void main()
{
int a[10][10],s=0,k=1,r,c,i=0,j=0,ch,t;
clrscr();
cout<<"ENTER NO OF ROWS AND COLUMNS\n\n";
cin>>r>>c;
if(r!=c)
cout<<"ENTERED MATRIX IS NOT SQUARE MATRIX\n\n";
else
{
cout<<"\n\nENTER MATRIX ELEMENTS\n\n";
for(i=1;i<=r;i++)
for(j=1;j<=c;j++)
cin>>a[i][j];
clrscr();
cout<<"1.RIGHT SIDE RIGHT ANGLE TRIANGLE\n\n"
"2. LEFT SIDE RIGHT ANGLE TRIANGLE\n\n";
cin>>ch;
for(i=1;i<=r;i++)
{
for(j=1;j<=c;j++)
cout<<"\t"<<a[i][j];
cout<<"\n\n";
}
cout<<"\n\nRIGHT ANGLED TRIANGLE IS:\n\n";
switch(ch)
{
case 1:
for(i=1;i<=r;i++)
{
for(j=1;j<=i;j++)
{
cout<<"\t"<<a[i][j];
s=s+a[i][j];
}
cout<<"\n\n";
}
break;
case 2:
for(i=1;i<=r;i++)
{
j=c-(i-1);
t=i;
for(k=i;k>=1;k--)
{
while(c>=t)
{
cout<<"\t";
t++;
}
cout<<"\t"<<a[i][j];
s=s+a[i][j];
j++;
}
cout<<"\n\n";
}
break;
}
cout<<"\n\nSUM IS : "<<s;
}
getch();
}


You forgot [code]code tags[/code]
He forgot to ask the question, too. But that's just a minor problem... Note the sarcasm.
my question is whether this is an efficient one r not..pls suggest
Topic archived. No new replies allowed.