I m working with a pattern program but facing one issue my condition is false then the condition is run?
Pattern Programme:
#include<iostream>
using namespace std;
int main()
{
int i,j,k,n;
std::cout << "Enter Number:" ;
cin>>n;
for(int i=1;i<=n;i++) //row
{
//first time condition false 1(k value)<1(i value) not execute first time this is ok
//second time condition false 2(k value)<2(i value) why this condition run when condition is false????
for(int k=1;k<i;k++) //space
{
cout << " ";
}
for(int j=i;j<=n;j++) //column
{
std::cout << "*" ;
}
cout << "\n";
}
}
execute of program:
ex: user enter 3
first time excite condition properly :
now i=1 and k=1
for(int i=1;1<=3;i++) //row
{
for(int k=1;1<1;k++) //space //1<1 false ok.
{
cout << " ";
}
Issue with second-time condition:
now i=2 and k=2
for(int i=1;2<=3;i++) //row
{
for(int k=1;2<2;k++) //space //2<2 false Not Ok problem is here why these condition is run
{
cout << " ";
}
Link Programme:https://onlinegdb.com/Hk9DHuwvL