+ 1
How to get an output like the following:
# ## ### #### for an input x=4, with proper white spaces.
6 Answers
+ 3
edit: implemented in c++
#include <iostream>
using namespace std;
int main() {
int i,j;
int input = 4;
for (i = 0; i<input ; i++){
for(j= 0;j<input;j++){
if(j >= (input-i-1))
{ cout << "#"; }
else{ cout << "quot;; } /*use spaces here instead of $ to run on terminal... use $ to run on soloLearn*/
}
cout << endl ;
}
return 0;
}
+ 3
#include <iostream>
using namespace std;
int main()
{
int i,j,n;
cout<<"Enter Input:\n";
cin>>n;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(j>=(n-i-1))
{
cout<<"#";
}
else
{
cout<<" ";
}
}
cout<<"\n";
}
return 0;
}
+ 1
you r welcome shahbaz ,
in those for loops if you initialize i = j = 1 then use '<=' condition in both loops and change the if condition 'if( j>= input -i)'
+ 1
Loops are the most interesting topic I've encountered till yet.
0
Thank you Kabira, just had to put a '<=' in the first loop.
0
Got you... ^_^



