0% found this document useful (0 votes)
30 views2 pages

Jelly

The document contains C++ code that uses nested for loops and if/else statements to print different patterns of the letter J and spaces. It prints 6 patterns in total by varying the loop bounds and conditional logic for each pattern.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views2 pages

Jelly

The document contains C++ code that uses nested for loops and if/else statements to print different patterns of the letter J and spaces. It prints 6 patterns in total by varying the loop bounds and conditional logic for each pattern.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <iostream>

using namespace std;


int main()
{
for (int b = 0; b <= 5; b++)
{
for (int a = 0; a <= 5; a++)
{
if (b == 0 || a == 2 || b == 5 && a <= 2)
{
cout << "J";
}
else
{
cout << " ";
}
}
cout <<endl;
}
cout << "\n";

for (int b = 0; b <= 6; b++)


{
for (int a = 0; a <= 6; a++)
{
if (b == 0 || a == 0 || b == 3 || b == 6)
{
cout << "J";
}
else
{
cout << " ";
}
}
cout << endl;
}
cout << "\n";

for (int b = 0; b <= 6; b++)


{
for (int a = 0; a <= 6; a++)
{
if (a == 0 || b == 6)
{
cout << "J";
}
else
{
cout << " ";
}
}
cout << endl;
}
cout << "\n";

for (int b = 0; b <= 6; b++)


{
for (int a = 0; a <= 6; a++)
{
if (a == 0 || b == 6)
{
cout << "J";
}
else
{
cout << " ";
}
}
cout <<endl;
}
cout << "\n";
for (int b = 0; b <= 6; b++)
{
for (int a = 0; a <= 6; a++)
{
if ( b == 6 && a==0||b==5 && a==1 ||b==4 && a==2||b==3 && a==3||
b==2 && a==4||b==1 && a==5||b==0 && a==6||b==3 && a==3||b==2 && a==2||b==1 &&a==1||b==0
&& a==0)
{
cout << "J";
}
else
{
cout << " ";
}
}
cout <<endl;
}
cout << "\n";

You might also like