Whenever you prepare for Interview you must be aware with printing patterns , In coding interview interviewer may ask you print any number pattern , star pattern or an character patterns. We recommend you to follow our patterns series so you will feel comfortable with printing patterns. In this blog post we have shared all alphabets patterns from A, B,C,D . . . . to Z with Java , CPP, Python and JavaScript.
We recommend you to solve other types patterns as well –
Now let’s get started with learning how to print a alphabets using simple code logic, click on the pattern and you will get redirected to the code.
Pattern A
*** * * * * ***** * * * * * *
Code to print A
Java
C++
Python
JavaScript
Java
public class MainClass { public static void main(String[] args) { for(int i=0;i<7;i++) { for(int j=0;j<5;j++) { if(j==0 && i!=0 || j==4 && i!=0 || i==0 && j!=0 && j!=4 || i==3 ) System.out.print("*"); else System.out.print(" "); } System.out.println(); } } }
C++
#includeint main() { for (int i = 0; i < 7; i++) { for (int j = 0; j < 5; j++) { if (j == 0 && i != 0 || j == 4 && i != 0 || i == 0 && j != 0 && j != 4 || i == 3) { std::cout << "*"; } else { std::cout << " "; } } std::cout << std::endl; } return 0; };
Python
class MainClass : @staticmethod def main( args) : i = 0 while (i < 7) : j = 0 while (j < 5) : if (j == 0 and i != 0 or j == 4 and i != 0 or i == 0 and j != 0 and j != 4 or i == 3) : print("*", end ="") else : print(" ", end ="") j += 1 print() i += 1 if __name__=="__main__": MainClass.main([])
JavaScript
class MainClass { static main(args) { for (i; i < 7; i++) { for (j; j < 5; j++) { if (j == 0 && i != 0 || j == 4 && i != 0 || i == 0 && j != 0 && j != 4 || i == 3) { console.log("*"); } else { console.log(" "); } } console.log(); } } } MainClass.main([]);
Pattern B
**** * * * * **** * * * * ****
Code to print B
Java
C++
Python
JavaScript
Java
public class MainClass { public static void main(String[] args) { for(int i=0;i<7;i++) { for(int j=0;j<5;j++) { if(j==0 || j==4 && i!=0 && i!=3 && i!=6|| i==0 && j!=4 || i==3 && j!=4 || i==6 && j!=4 ) System.out.print("*"); else System.out.print(" "); } System.out.println(); } } }
C++
#includeint main() { for (int i = 0; i < 7; i++) { for (int j = 0; j < 5; j++) { if (j == 0 || j == 4 && i != 0 && i != 3 && i != 6 || i == 0 && j != 4 || i == 3 && j != 4 || i == 6 && j != 4) { std::cout << "*"; } else { std::cout << " "; } } std::cout << std::endl; } return 0; };
Python
class MainClass : @staticmethod def main( args) : i = 0 while (i < 7) : j = 0 while (j < 5) : if (j == 0 or j == 4 and i != 0 and i != 3 and i != 6 or i == 0 and j != 4 or i == 3 and j != 4 or i == 6 and j != 4) : print("*", end ="") else : print(" ", end ="") j += 1 print() i += 1 if __name__=="__main__": MainClass.main([])
JavaScript
class MainClass { static main(args) { for (i; i < 7; i++) { for (j; j < 5; j++) { if (j == 0 || j == 4 && i != 0 && i != 3 && i != 6 || i == 0 && j != 4 || i == 3 && j != 4 || i == 6 && j != 4) { console.log("*"); } else { console.log(" "); } } console.log(); } } } MainClass.main([]);
Pattern C
**** * * * * ****
Code to print C
Java
C++
Python
JavaScript
Java
public class MainClass { public static void main(String[] args) { for(int i=0;i<7;i++) { for(int j=0;j<5;j++) { if(j==0 && i!=0 && i!=5 || i==0 && j!=0 || i==5 && j!=0) System.out.print("*"); else System.out.print(" "); } System.out.println(); } } }
C++
#includeint main() { for (int i = 0; i < 7; i++) { for (int j = 0; j < 5; j++) { if (j == 0 && i != 0 && i != 5 || i == 0 && j != 0 || i == 5 && j != 0) { std::cout << "*"; } else { std::cout << " "; } } std::cout << std::endl; } return 0; };
Python
class MainClass : @staticmethod def main( args) : i = 0 while (i < 7) : j = 0 while (j < 5) : if (j == 0 and i != 0 and i != 5 or i == 0 and j != 0 or i == 5 and j != 0) : print("*", end ="") else : print(" ", end ="") j += 1 print() i += 1 if __name__=="__main__": MainClass.main([])
JavaScript
class MainClass { static main(args) { for (i; i < 7; i++) { for (j; j < 5; j++) { if (j == 0 && i != 0 && i != 5 || i == 0 && j != 0 || i == 5 && j != 0) { console.log("*"); } else { console.log(" "); } } console.log(); } } } MainClass.main([]);
Pattern D
**** * * * * * * * * * * ****
Code to print D
Java
C++
Python
JavaScript
Java
public class MainClass { public static void main(String[] args) { for(int i=0;i<7;i++) { for(int j=0;j<5;j++) { if(j==0 || i==0 && j!=4 || j==4 && i!=0 && i!=6 || i==6 && j!=4 ) System.out.print("*"); else System.out.print(" "); } System.out.println(); } } }
C++
#includeint main() { for (int i = 0; i < 7; i++) { for (int j = 0; j < 5; j++) { if (j == 0 || i == 0 && j != 4 || j == 4 && i != 0 && i != 6 || i == 6 && j != 4) { std::cout << "*"; } else { std::cout << " "; } } std::cout << std::endl; } return 0; };
Python
class MainClass : @staticmethod def main( args) : i = 0 while (i < 7) : j = 0 while (j < 5) : if (j == 0 or i == 0 and j != 4 or j == 4 and i != 0 and i != 6 or i == 6 and j != 4) : print("*", end ="") else : print(" ", end ="") j += 1 print() i += 1 if __name__=="__main__": MainClass.main([])
JavaScript
class MainClass { static main(args) { for (i; i < 7; i++) { for (j; j < 5; j++) { if (j == 0 || i == 0 && j != 4 || j == 4 && i != 0 && i != 6 || i == 6 && j != 4) { console.log("*"); } else { console.log(" "); } } console.log(); } } } MainClass.main([]);
Pattern E
***** * * ***** * * *****
Code to print E
Java
C++
Python
JavaScript
Java
public class MainClass {
public static void main(String[] args) {
for(int i=0;i<7;i++) {
for(int j=0;j<5;j++) {
if(j==0 || i==0 || i==3 || i==6)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}
C++
#include
int main() {
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 5; j++) {
if (j == 0 || i == 0 || i == 3 || i == 6) {
std::cout << "*";
} else {
std::cout << " ";
}
}
std::cout << std::endl;
}
return 0;
};
Python
class MainClass :
@staticmethod
def main( args) :
i = 0
while (i < 7) :
j = 0
while (j < 5) :
if (j == 0 or i == 0 or i == 3 or i == 6) :
print("*", end ="")
else :
print(" ", end ="")
j += 1
print()
i += 1
if __name__=="__main__":
MainClass.main([])
JavaScript
class MainClass {
static main(args) {
for (i; i < 7; i++) {
for (j; j < 5; j++) {
if (j == 0 || i == 0 || i == 3 || i == 6) {
console.log("*");
} else {
console.log(" ");
}
}
console.log();
}
}
}
MainClass.main([]);
Pattern F
***** * * ***** * * *
Code to print F
Java
C++
Python
JavaScript
Java
public class MainClass {
public static void main(String[] args) {
for(int i=0;i<7;i++) {
for(int j=0;j<5;j++) {
if(j==0 || i==0 || i==3)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}
C++
#include
int main() {
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 5; j++) {
if (j == 0 || i == 0 || i == 3) {
std::cout << "*";
} else {
std::cout << " ";
}
}
std::cout << std::endl;
}
return 0;
};
Python
class MainClass :
@staticmethod
def main( args) :
i = 0
while (i < 7) :
j = 0
while (j < 5) :
if (j == 0 or i == 0 or i == 3) :
print("*", end ="")
else :
print(" ", end ="")
j += 1
print()
i += 1
if __name__=="__main__":
MainClass.main([])
JavaScript
class MainClass {
static main(args) {
for (i; i < 7; i++) {
for (j; j < 5; j++) {
if (j == 0 || i == 0 || i == 3) {
console.log("*");
} else {
console.log(" ");
}
}
console.log();
}
}
}
MainClass.main([]);
Pattern G
***** * * * ** * * * * *****
Code to print G
Java
C++
Python
JavaScript
Java
public class MainClass { public static void main(String[] args) { for(int i=0;i<7;i++) { for(int j=0;j<5;j++) { if(j==0 || i==0 && j!=5 || i==6 && j!=5|| i==3 && j!=1 && j!=2 || j==4 && i!=1 && i!=2) System.out.print("*"); else System.out.print(" "); } System.out.println(); } } }
C++
#includeint main() { for (int i = 0; i < 7; i++) { for (int j = 0; j < 5; j++) { if (j == 0 || i == 0 && j != 5 || i == 6 && j != 5 || i == 3 && j != 1 && j != 2 || j == 4 && i != 1 && i != 2) { std::cout << "*"; } else { std::cout << " "; } } std::cout << std::endl; } return 0; };
Python
class MainClass : @staticmethod def main( args) : i = 0 while (i < 7) : j = 0 while (j < 5) : if (j == 0 or i == 0 and j != 5 or i == 6 and j != 5 or i == 3 and j != 1 and j != 2 or j == 4 and i != 1 and i != 2) : print("*", end ="") else : print(" ", end ="") j += 1 print() i += 1 if __name__=="__main__": MainClass.main([])
JavaScript
class MainClass { static main(args) { for (i; i < 7; i++) { for (j; j < 5; j++) { if (j == 0 || i == 0 && j != 5 || i == 6 && j != 5 || i == 3 && j != 1 && j != 2 || j == 4 && i != 1 && i != 2) { console.log("*"); } else { console.log(" "); } } console.log(); } } } MainClass.main([]);
Pattern H
* * * * * * ***** * * * * * *
Code to print H
Java
C++
Python
JavaScript
Java
public class MainClass {
public static void main(String[] args) {
for(int i=0;i<7;i++) {
for(int j=0;j<5;j++) {
if(j==0 || i==3 || j==4)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}
C++
#include
int main() {
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 5; j++) {
if (j == 0 || i == 3 || j == 4) {
std::cout << "*";
} else {
std::cout << " ";
}
}
std::cout << std::endl;
}
return 0;
};
Python
class MainClass :
@staticmethod
def main( args) :
i = 0
while (i < 7) :
j = 0
while (j < 5) :
if (j == 0 or i == 3 or j == 4) :
print("*", end ="")
else :
print(" ", end ="")
j += 1
print()
i += 1
if __name__=="__main__":
MainClass.main([])
JavaScript
class MainClass {
static main(args) {
for (i; i < 7; i++) {
for (j; j < 5; j++) {
if (j == 0 || i == 3 || j == 4) {
console.log("*");
} else {
console.log(" ");
}
}
console.log();
}
}
}
MainClass.main([]);
Pattern I
***** * * * * * *****
Code to print I
Java
C++
Python
JavaScript
Java
public class MainClass {
public static void main(String[] args) {
for(int i=0;i<7;i++) {
for(int j=0;j<5;j++) {
if(j==2 || i==0 || i==6)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}
C++
#include
int main() {
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 5; j++) {
if (j == 2 || i == 0 || i == 6) {
std::cout << "*";
} else {
std::cout << " ";
}
}
std::cout << std::endl;
}
return 0;
};
Python
class MainClass :
@staticmethod
def main( args) :
i = 0
while (i < 7) :
j = 0
while (j < 5) :
if (j == 2 or i == 0 or i == 6) :
print("*", end ="")
else :
print(" ", end ="")
j += 1
print()
i += 1
if __name__=="__main__":
MainClass.main([])
JavaScript
class MainClass {
static main(args) {
for (i; i < 7; i++) {
for (j; j < 5; j++) {
if (j == 2 || i == 0 || i == 6) {
console.log("*");
} else {
console.log(" ");
}
}
console.log();
}
}
}
MainClass.main([]);
Pattern J
***** * * * * * * ***
Code to print J
Java
C++
Python
JavaScript
Java
public class MainClass { public static void main(String[] args) { for(int i=0;i<7;i++) { for(int j=0;j<5;j++) { if(j==2 || i==0 || i==6 && j!=3 && j!=4 || i==5 && j!=3 && j!=4 && j!=1) System.out.print("*"); else System.out.print(" "); } System.out.println(); } } }
C++
#includeint main() { for (int i = 0; i < 7; i++) { for (int j = 0; j < 5; j++) { if (j == 2 || i == 0 || i == 6 && j != 3 && j != 4 || i == 5 && j != 3 && j != 4 && j != 1) { std::cout << "*"; } else { std::cout << " "; } } std::cout << std::endl; } return 0; };
Python
class MainClass : @staticmethod def main( args) : i = 0 while (i < 7) : j = 0 while (j < 5) : if (j == 2 or i == 0 or i == 6 and j != 3 and j != 4 or i == 5 and j != 3 and j != 4 and j != 1) : print("*", end ="") else : print(" ", end ="") j += 1 print() i += 1 if __name__=="__main__": MainClass.main([])
JavaScript
class MainClass { static main(args) { for (i; i < 7; i++) { for (j; j < 5; j++) { if (j == 2 || i == 0 || i == 6 && j != 3 && j != 4 || i == 5 && j != 3 && j != 4 && j != 1) { console.log("*"); } else { console.log(" "); } } console.log(); } } } MainClass.main([]);
Pattern K
* * * * * * ** * * * * * *
Code to print K
Java
C++
Python
JavaScript
Java
public class MainClass {
public static void main(String[] args) {
for(int i=0;i<7;i++) {
for(int j=0;j<5;j++) {
if(j==0 || j+i==4 || j-i==-2)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}
C++
#include
int main() {
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 5; j++) {
if (j == 0 || j + i == 4 || j - i == -2) {
std::cout << "*";
} else {
std::cout << " ";
}
}
std::cout << std::endl;
}
return 0;
};
Python
class MainClass :
@staticmethod
def main( args) :
i = 0
while (i < 7) :
j = 0
while (j < 5) :
if (j == 0 or j + i == 4 or j - i == -2) :
print("*", end ="")
else :
print(" ", end ="")
j += 1
print()
i += 1
if __name__=="__main__":
MainClass.main([])
JavaScript
class MainClass {
static main(args) {
for (i; i < 7; i++) {
for (j; j < 5; j++) {
if (j == 0 || j + i == 4 || j - i == -2) {
console.log("*");
} else {
console.log(" ");
}
}
console.log();
}
}
}
MainClass.main([]);
Pattern L
* * * * * * *****
Code to print L
Java
C++
Python
JavaScript
Java
public class MainClass {
public static void main(String[] args) {
for(int i=0;i<7;i++) {
for(int j=0;j<5;j++) {
if(j==0 || i==6)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}
C++
#include
int main() {
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 5; j++) {
if (j == 0 || i == 6) {
std::cout << "*";
} else {
std::cout << " ";
}
}
std::cout << std::endl;
}
return 0;
};
Python
class MainClass :
@staticmethod
def main( args) :
i = 0
while (i < 7) :
j = 0
while (j < 5) :
if (j == 0 or i == 6) :
print("*", end ="")
else :
print(" ", end ="")
j += 1
print()
i += 1
if __name__=="__main__":
MainClass.main([])
JavaScript
class MainClass {
static main(args) {
for (i; i < 7; i++) {
for (j; j < 5; j++) {
if (j == 0 || i == 6) {
console.log("*");
} else {
console.log(" ");
}
}
console.log();
}
}
}
MainClass.main([]);
Pattern M
* * ** ** * * * * * * * * * * * * *
Code to print M
Java
C++
Python
JavaScript
Java
public class MainClass {
public static void main(String[] args) {
for(int i=0;i<7;i++) {
for(int j=0;j<7;j++) {
if(j==0 || j-i==0 && i<=3 || j+i==6 && i<=3 || j==6)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}
C++
#include
int main() {
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 7; j++) {
if (j == 0 || j - i == 0 && i <= 3 || j + i == 6 && i <= 3 || j == 6) {
std::cout << "*";
} else {
std::cout << " ";
}
}
std::cout << std::endl;
}
return 0;
};
Python
class MainClass :
@staticmethod
def main( args) :
i = 0
while (i < 7) :
j = 0
while (j < 7) :
if (j == 0 or j - i == 0 and i <= 3 or j + i == 6 and i <= 3 or j == 6) :
print("*", end ="")
else :
print(" ", end ="")
j += 1
print()
i += 1
if __name__=="__main__":
MainClass.main([])
JavaScript
class MainClass {
static main(args) {
for (i; i < 7; i++) {
for (j; j < 7; j++) {
if (j == 0 || j - i == 0 && i <= 3 || j + i == 6 && i <= 3 || j == 6) {
console.log("*");
} else {
console.log(" ");
}
}
console.log();
}
}
}
MainClass.main([]);
Pattern N
* * ** * * * * * * * * * * * ** * *
Code to print N
Java
C++
Python
JavaScript
Java
public class MainClass {
public static void main(String[] args) {
for(int i=0;i<7;i++) {
for(int j=0;j<7;j++) {
if(j==0 || j-i==0 || j==6)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}
C++
#include
int main() {
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 7; j++) {
if (j == 0 || j - i == 0 || j == 6) {
std::cout << "*";
} else {
std::cout << " ";
}
}
std::cout << std::endl;
}
return 0;
};
Python
class MainClass :
@staticmethod
def main( args) :
i = 0
while (i < 7) :
j = 0
while (j < 7) :
if (j == 0 or j - i == 0 or j == 6) :
print("*", end ="")
else :
print(" ", end ="")
j += 1
print()
i += 1
if __name__=="__main__":
MainClass.main([])
JavaScript
#include
int main() {
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 7; j++) {
if (j == 0 || j - i == 0 || j == 6) {
std::cout << "*";
} else {
std::cout << " ";
}
}
std::cout << std::endl;
}
return 0;
};
Pattern O
*** * * * * * * * * * * ***
Code to print O
Java
C++
Python
JavaScript
Java
public class MainClass { public static void main(String[] args) { for(int i=0;i<7;i++) { for(int j=0;j<5;j++) { if(j==0 && i!=0 && i!=6 || i==0 && j!=4 && j!=0 || j==4 && i!=0 && i!=6 || i==6 && j!=4 && j!=0 ) System.out.print("*"); else System.out.print(" "); } System.out.println(); } } }
C++
#includeint main() { for (int i = 0; i < 7; i++) { for (int j = 0; j < 5; j++) { if (j == 0 && i != 0 && i != 6 || i == 0 && j != 4 && j != 0 || j == 4 && i != 0 && i != 6 || i == 6 && j != 4 && j != 0) { std::cout << "*"; } else { std::cout << " "; } } std::cout << std::endl; } return 0; };
Python
class MainClass : @staticmethod def main( args) : i = 0 while (i < 7) : j = 0 while (j < 5) : if (j == 0 and i != 0 and i != 6 or i == 0 and j != 4 and j != 0 or j == 4 and i != 0 and i != 6 or i == 6 and j != 4 and j != 0) : print("*", end ="") else : print(" ", end ="") j += 1 print() i += 1 if __name__=="__main__": MainClass.main([])
JavaScript
class MainClass { static main(args) { for (i; i < 7; i++) { for (j; j < 5; j++) { if (j == 0 && i != 0 && i != 6 || i == 0 && j != 4 && j != 0 || j == 4 && i != 0 && i != 6 || i == 6 && j != 4 && j != 0) { console.log("*"); } else { console.log(" "); } } console.log(); } } } MainClass.main([]);
Pattern P
*** * * * * **** * * *
Code to print P
Java
C++
Python
JavaScript
Java
public class MainClass { public static void main(String[] args) { for(int i=0;i<7;i++) { for(int j=0;j<5;j++) { if(j==0 && i!=0 || i==0 && j!=0 && j!=4 || j==4 && i!=0 && i<=2 || i==3 && j!=4) System.out.print("*"); else System.out.print(" "); } System.out.println(); } } }
C++
#includeint main() { for (int i = 0; i < 7; i++) { for (int j = 0; j < 5; j++) { if (j == 0 && i != 0 || i == 0 && j != 0 && j != 4 || j == 4 && i != 0 && i <= 2 || i == 3 && j != 4) { std::cout << "*"; } else { std::cout << " "; } } std::cout << std::endl; } return 0; };
Python
class MainClass : @staticmethod def main( args) : i = 0 while (i < 7) : j = 0 while (j < 5) : if (j == 0 and i != 0 or i == 0 and j != 0 and j != 4 or j == 4 and i != 0 and i <= 2 or i == 3 and j != 4) : print("*", end ="") else : print(" ", end ="") j += 1 print() i += 1 if __name__=="__main__": MainClass.main([])
JavaScript
class MainClass { static main(args) { for (i; i < 7; i++) { for (j; j < 5; j++) { if (j == 0 && i != 0 || i == 0 && j != 0 && j != 4 || j == 4 && i != 0 && i <= 2 || i == 3 && j != 4) { console.log("*"); } else { console.log(" "); } } console.log(); } } } MainClass.main([]);
Pattern R
*** * * * * **** * * * * * *
Code to print R
Java
C++
Python
JavaScript
Java
public class MainClass { public static void main(String[] args) { for(int i=0;i<7;i++) { for(int j=0;j<5;j++) { if(j==0 && i!=0 || i==0 && j!=0 && j!=4 || j==4 && i!=0 && i!=3 || i==3 && j!=4) System.out.print("*"); else System.out.print(" "); } System.out.println(); } } }
C++
#includeint main() { for (int i = 0; i < 7; i++) { for (int j = 0; j < 5; j++) { if (j == 0 && i != 0 || i == 0 && j != 0 && j != 4 || j == 4 && i != 0 && i != 3 || i == 3 && j != 4) { std::cout << "*"; } else { std::cout << " "; } } std::cout << std::endl; } return 0; };
Python
class MainClass : @staticmethod def main( args) : i = 0 while (i < 7) : j = 0 while (j < 5) : if (j == 0 and i != 0 or i == 0 and j != 0 and j != 4 or j == 4 and i != 0 and i != 3 or i == 3 and j != 4) : print("*", end ="") else : print(" ", end ="") j += 1 print() i += 1 if __name__=="__main__": MainClass.main([])
JavaScript
class MainClass { static main(args) { for (i; i < 7; i++) { for (j; j < 5; j++) { if (j == 0 && i != 0 || i == 0 && j != 0 && j != 4 || j == 4 && i != 0 && i != 3 || i == 3 && j != 4) { console.log("*"); } else { console.log(" "); } } console.log(); } } } MainClass.main([]);
Pattern S
***** * * ***** * * *****
Code to print S
Java
C++
Python
JavaScript
Java
public class MainClass { public static void main(String[] args) { for(int i=0;i<7;i++) { for(int j=0;j<5;j++) { if(j==0 && i<=3 || i==0 || i==3 || i==6 || j==4 && i>=4) System.out.print("*"); else System.out.print(" "); } System.out.println(); } } }
C++
#includeint main() { for (int i = 0; i < 7; i++) { for (int j = 0; j < 5; j++) { if (j == 0 && i <= 3 || i == 0 || i == 3 || i == 6 || j == 4 && i >= 4) { std::cout << "*"; } else { std::cout << " "; } } std::cout << std::endl; } return 0; };
Python
class MainClass : @staticmethod def main( args) : i = 0 while (i < 7) : j = 0 while (j < 5) : if (j == 0 and i <= 3 or i == 0 or i == 3 or i == 6 or j == 4 and i >= 4) : print("*", end ="") else : print(" ", end ="") j += 1 print() i += 1 if __name__=="__main__": MainClass.main([])
JavaScript
class MainClass { static main(args) { for (i; i < 7; i++) { for (j; j < 5; j++) { if (j == 0 && i <= 3 || i == 0 || i == 3 || i == 6 || j == 4 && i >= 4) { console.log("*"); } else { console.log(" "); } } console.log(); } } } MainClass.main([]);
Pattern T
***** * * * * * *
Code to print T
Java
C++
Python
JavaScript
Java
public class MainClass {
public static void main(String[] args) {
for(int i=0;i<7;i++) {
for(int j=0;j<5;j++) {
if(j==2 || i==0)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}
C++
console.log( 'Code is Poetry' );#include
int main() {
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 5; j++) {
if (j == 2 || i == 0) {
std::cout << "*";
} else {
std::cout << " ";
}
}
std::cout << std::endl;
}
return 0;
};
Python
class MainClass :
@staticmethod
def main( args) :
i = 0
while (i < 7) :
j = 0
while (j < 5) :
if (j == 2 or i == 0) :
print("*", end ="")
else :
print(" ", end ="")
j += 1
print()
i += 1
if __name__=="__main__":
MainClass.main([])
JavaScript
class MainClass {
static main(args) {
for (i; i < 7; i++) {
for (j; j < 5; j++) {
if (j == 2 || i == 0) {
console.log("*");
} else {
console.log(" ");
}
}
console.log();
}
}
}
MainClass.main([]);
Pattern U
* * * * * * * * * * * * ***
Code to print U
Java
C++
Python
JavaScript
Java
public class MainClass { public static void main(String[] args) { for(int i=0;i<7;i++) { for(int j=0;j<5;j++) { if(j==0 && i!=6 || i==6 && j!=0 && j!=4 || j==4 && i!=6) System.out.print("*"); else System.out.print(" "); } System.out.println(); } } }
C++
#includeint main() { for (int i = 0; i < 7; i++) { for (int j = 0; j < 5; j++) { if (j == 0 && i != 6 || i == 6 && j != 0 && j != 4 || j == 4 && i != 6) { std::cout << "*"; } else { std::cout << " "; } } std::cout << std::endl; } return 0; };
Python
class MainClass : @staticmethod def main( args) : i = 0 while (i < 7) : j = 0 while (j < 5) : if (j == 0 and i != 6 or i == 6 and j != 0 and j != 4 or j == 4 and i != 6) : print("*", end ="") else : print(" ", end ="") j += 1 print() i += 1 if __name__=="__main__": MainClass.main([])
JavaScript
class MainClass { static main(args) { for (i; i < 7; i++) { for (j; j < 5; j++) { if (j == 0 && i != 6 || i == 6 && j != 0 && j != 4 || j == 4 && i != 6) { console.log("*"); } else { console.log(" "); } } console.log(); } } } MainClass.main([]);
Pattern V
* * * * * * * * * * * * *
Code to print V
Java
C++
Python
JavaScript
Java
public class MainClass {
public static void main(String[] args) {
for(int i=0;i<7;i++) {
for(int j=0;j<13;j++) {
if(j-i==0 || j+i==12 )
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}
C++
#include
int main() {
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 13; j++) {
if (j - i == 0 || j + i == 12) {
std::cout << "*";
} else {
std::cout << " ";
}
}
std::cout << std::endl;
}
return 0;
};
Python
class MainClass :
@staticmethod
def main( args) :
i = 0
while (i < 7) :
j = 0
while (j < 13) :
if (j - i == 0 or j + i == 12) :
print("*", end ="")
else :
print(" ", end ="")
j += 1
print()
i += 1
if __name__=="__main__":
MainClass.main([])
JavaScript
class MainClass {
static main(args) {
for (i; i < 7; i++) {
for (j; j < 13; j++) {
if (j - i == 0 || j + i == 12) {
console.log("*");
} else {
console.log(" ");
}
}
console.log();
}
}
}
MainClass.main([]);
Pattern W
* * * * * * * ** ** * *
Code to print W
Java
C++
Python
JavaScript
Java
public class MainClass {
public static void main(String[] args) {
for(int i=0;i<4;i++) {
for(int j=0;j<7;j++) {
if(j==0 || j+i==3 || j-i==3 || j==6 )
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}
C++
#include
int main() {
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 7; j++) {
if (j == 0 || j + i == 3 || j - i == 3 || j == 6) {
std::cout << "*";
} else {
std::cout << " ";
}
}
std::cout << std::endl;
}
return 0;
};
Python
class MainClass :
@staticmethod
def main( args) :
i = 0
while (i < 4) :
j = 0
while (j < 7) :
if (j == 0 or j + i == 3 or j - i == 3 or j == 6) :
print("*", end ="")
else :
print(" ", end ="")
j += 1
print()
i += 1
if __name__=="__main__":
MainClass.main([])
JavaScript
class MainClass {
static main(args) {
for (i; i < 4; i++) {
for (j; j < 7; j++) {
if (j == 0 || j + i == 3 || j - i == 3 || j == 6) {
console.log("*");
} else {
console.log(" ");
}
}
console.log();
}
}
}
MainClass.main([]);
Pattern X
* * * * * * * * * * * * *
Code to print X
Java
C++
Python
JavaScript
Java
public class MainClass {
public static void main(String[] args) {
for(int i=0;i<7;i++) {
for(int j=0;j<7;j++) {
if(j-i==0 || j+i==6)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}
C++
#include
int main() {
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 7; j++) {
if (j - i == 0 || j + i == 6) {
std::cout << "*";
} else {
std::cout << " ";
}
}
std::cout << std::endl;
}
return 0;
};
Python
class MainClass :
@staticmethod
def main( args) :
i = 0
while (i < 7) :
j = 0
while (j < 7) :
if (j - i == 0 or j + i == 6) :
print("*", end ="")
else :
print(" ", end ="")
j += 1
print()
i += 1
if __name__=="__main__":
MainClass.main([])
JavaScript
class MainClass {
static main(args) {
for (i; i < 7; i++) {
for (j; j < 7; j++) {
if (j - i == 0 || j + i == 6) {
console.log("*");
} else {
console.log(" ");
}
}
console.log();
}
}
}
MainClass.main([]);
Pattern Y
* * * * * * * * * *
Code to print Y
Java
C++
Python
JavaScript
Java
public class MainClass { public static void main(String[] args) { for(int i=0;i<7;i++) { for(int j=0;j<7;j++) { if(j-i==0 && i<=3|| j+i==6 && i<=3 || j==3 && i>=3) System.out.print("*"); else System.out.print(" "); } System.out.println(); } } }
C++
#includeint main() { for (int i = 0; i < 7; i++) { for (int j = 0; j < 7; j++) { if (j - i == 0 && i <= 3 || j + i == 6 && i <= 3 || j == 3 && i >= 3) { std::cout << "*"; } else { std::cout << " "; } } std::cout << std::endl; } return 0; };
Python
class MainClass : @staticmethod def main( args) : i = 0 while (i < 7) : j = 0 while (j < 7) : if (j - i == 0 and i <= 3 or j + i == 6 and i <= 3 or j == 3 and i >= 3) : print("*", end ="") else : print(" ", end ="") j += 1 print() i += 1 if __name__=="__main__": MainClass.main([])
JavaScript
class MainClass { static main(args) { for (i; i < 7; i++) { for (j; j < 7; j++) { if (j - i == 0 && i <= 3 || j + i == 6 && i <= 3 || j == 3 && i >= 3) { console.log("*"); } else { console.log(" "); } } console.log(); } } } MainClass.main([]);
Pattern Z
******* * * * * * *******
Code to print Z
Java
C++
Python
JavaScript
Java
public class MainClass {
public static void main(String[] args) {
for(int i=0;i<7;i++) {
for(int j=0;j<7;j++) {
if(i==0 || j+i==6 || i==6)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}
C++
#include
int main() {
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 7; j++) {
if (i == 0 || j + i == 6 || i == 6) {
std::cout << "*";
} else {
std::cout << " ";
}
}
std::cout << std::endl;
}
return 0;
};
Python
class MainClass :
@staticmethod
def main( args) :
i = 0
while (i < 7) :
j = 0
while (j < 7) :
if (i == 0 or j + i == 6 or i == 6) :
print("*", end ="")
else :
print(" ", end ="")
j += 1
print()
i += 1
if __name__=="__main__":
MainClass.main([])
JavaScript
class MainClass {
static main(args) {
for (i; i < 7; i++) {
for (j; j < 7; j++) {
if (i == 0 || j + i == 6 || i == 6) {
console.log("*");
} else {
console.log(" ");
}
}
console.log();
}
}
}
MainClass.main([]);