how to make a program which the out put is:
enter n=5
1 2 3 4 5 4 3 2 1
2 3 4 5 4 3 2
3 4 5 4 3
4 5 4
5
this is the code i use but an error occur
#include <iostream.h>
void main()
{
int a=10;
int n,i,j=0,k;
cout<<"Enter the value for n: ";
cin>>n;
k=n;
for (i=0 ;i < 10; i++)
a[I]=i + 1; [/I]
[I]while(k>0){ [/I]
[I]for(i=(0+j);i<n;i++) [/I]
[I]cout<<a[I]<<" "; [/I]
[I]for(i=n-2;i>=(0+j);i--) [/I]
[I]cout<<a[I]<<" "; [/I]
[I]cout<<endl; [/I]
[I]j++; [/I]
[I]for(i=0;i<j;i++) [/I]
[I]cout<<" "; [/I]
[I]k--; [/I]
[I]} [/I]
[/I][/I]
another i really need to fin the proper code for factorial using successive addition
this is the code i use
int main()
{
int num, fact = 6,temp =1,i ,j;
cout<<"Enter a factorial ";
cin>>num;
for(i=2;i<=num;i++)
fact=0;
{for(j=1;j<=1;j++)-------said code dosnt have effect
fact=fact+temp;
temp=fact;
}
}
please someone help me...thanks