So this is my code, what i am asking is,does outer loop set j to 0 every time outer loop iterates?
Like, first loop i = 0, check if i is <= 5 then go to the inner loop, j=0, check if j is <= i then print "*" then add +1 to j then end inner loop, and an endline.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <iostream>
usingnamespace std;
int main()
{
for (int i=0; i <=5; i++)
{
for (int j=0;j<=i ; j++)
{
cout << "*";
}
cout << endl;
}
return 0;
}
#include <iostream>
usingnamespace std;
int main()
{
int sayi;
cout <<"Bir tek sayi giriniz >"; // enter an odd number is the meaning of this sayi=number :D
cin >> sayi;
for (int i=0; i <=sayi; i+=2)
{
for (int k=0; k <=sayi-i/2; k++)
{
cout << " " ;
}
for (int j=0; j<=i ; j++)
{
cout << "*";
}
cout << endl;
}
for (int a=0; a <=sayi; a+=2)
{
for (int b=sayi/2; b <=sayi+a/2; b++)
{
cout << " " ;
}
for (int c=0; c<sayi-a; c++)
{
cout << "*";
}
cout << endl;
}
return 0;
}