Forum Replies Created
Viewing 1 post (of 1 total)
- AuthorPosts
- starfishParticipant
hi frd,
just see if u can find this appropriate….
1234567891011121314151617181920212223242526272829303132333435363738#include <iostream><br />using namespace std;<br /><br />main(){<br /><br />int a[10];<br />int n,i,j=0,k;<br /><br />cout<<"Enter the value for n: ";<br />cin>>n;<br />k=n;<br /><br />for (i=0 ;i < 10; i++)<br />a=i + 1;<br /><br />while(k>0){<br />for(i=(0+j);i<n;i++)<br />cout<<a<<" ";<br />for(i=n-2;i>=(0+j);i--)<br />cout<<a<<" ";<br />cout<<endl;<br />j++;<br />for(i=0;i<j;i++)<br />cout<<" ";<br />k--;<br />}<br /><br />return 0;<br />}<br /><br />Output :<br /><br />Enter the value for n: 5<br />1 2 3 4 5 4 3 2 1<br />2 3 4 5 4 3 2<br />3 4 5 4 3<br />4 5 4<br />5 </iostream>plz let me know if you have any further queries
- AuthorPosts
Viewing 1 post (of 1 total)