Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Program to print Happy Holi

  • Difficulty Level : Easy
  • Last Updated : 19 Jul, 2018

Festival of Holi is around the corner and to all the coding geeks around there, let it be more than just a holiday and learn how can we wish our coding friends and surprise them with a code wish. HpY Holi 🙂

C++




// CPP program to print Happy Holi
#include <bits/stdc++.h>
using namespace std;
  
int main()
{
    // Print first row
    // You can choose any char
    char ch = '@';
    for (int i = 1; i <= 34; i++) {
        if (i == 4 || i == 7 || i == 10 || 
           i == 11 || i == 14 || i == 15 || 
           i == 16 || i == 17 || i == 19 || 
           i == 20 || i == 21 || i == 22 || 
           i == 24 || i == 27)
            cout << ch;
        else
            cout << " ";
    }
  
    // Print second row
    cout << endl;
    for (int i = 1; i <= 34; i++) {
        if (i == 4 || i == 7 || i == 9 ||
           i == 12 || i == 14 || i == 17 ||
           i == 19 || i == 22 || i == 24 || 
           i == 27)
            cout << ch;
        else
            cout << " ";
    }
  
    // Print third row
    cout << endl;
    for (int i = 1; i <= 34; i++) {
        if (i == 4 || i == 5 || i == 6 ||
           i == 7 || i == 9 || i == 10 || 
           i == 11 || i == 12 || i == 14 || 
           i == 15 || i == 16 || i == 17 || 
           i == 19 || i == 20 || i == 21 || 
           i == 22 || i == 25 || i == 26)
            cout << ch;
        else
            cout << " ";
    }
  
    // Print fourth row
    cout << endl;
    for (int i = 1; i <= 34; i++) {
        if (i == 4 || i == 7 || i == 9 || 
           i == 12 || i == 14 || i == 19 || 
           i == 25 || i == 26)
            cout << ch;
        else
            cout << " ";
    }
  
    // Print fifth row
    cout << endl;
    for (int i = 1; i <= 34; i++) {
        if (i == 4 || i == 7 || i == 9 || i == 12 ||
           i == 14 || i == 19 || i == 25 || i == 26)
            cout << ch;
        else
            cout << " ";
    }
  
    // Happy is printed, now print
    // Holi row by row
    cout << endl;
    cout << endl;
    cout << endl;
  
    // Print first row
    for (int i = 1; i <= 34; i++) {
        if (i == 4 || i == 7 || i == 10 || i == 11 || 
           i == 14 || i == 19 || i == 20 || i == 21 || 
           i == 22)
            cout << ch;
        else
            cout << " ";
    }
  
    // Print second row
    cout << endl;
    for (int i = 1; i <= 34; i++) {
        if (i == 4 || i == 7 || i == 9 || i == 12 ||
           i == 14 || i == 20 || i == 21)
            cout << ch;
        else
            cout << " ";
    }
  
    // Print third row
    cout << endl;
    for (int i = 1; i <= 34; i++) {
        if (i == 4 || i == 5 || i == 6 || i == 7 ||
           i == 9 || i == 12 || i == 14 || i == 20 || 
           i == 21)
            cout << ch;
        else
            cout << " ";
    }
  
    // Print fourth row
    cout << endl;
    for (int i = 1; i <= 34; i++) {
        if (i == 4 || i == 7 || i == 9 || i == 12 || 
           i == 14 || i == 20 || i == 21)
            cout << ch;
        else
            cout << " ";
    }
  
    // Print fifth row
    cout << endl;
    for (int i = 1; i <= 34; i++) {
        if (i == 4 || i == 7 || i == 10 || i == 11 || 
           i == 14 || i == 15 || i == 16 || i == 17 || 
           i == 19 || i == 20 || i == 21 || i == 22)
            cout << ch;
        else
            cout << " ";
    }
}

Java




// Java program to print Happy Holi
import java.io.*;
  
class GFG 
{
      
    public static void main (String[] args) 
    {
        // Print first row
        // You can choose any char
        char ch = '@';
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 10 || 
            i == 11 || i == 14 || i == 15 || 
            i == 16 || i == 17 || i == 19 || 
            i == 20 || i == 21 || i == 22 || 
            i == 24 || i == 27)
                System.out.print(ch);
            else
                System.out.print(" ");
        }
      
        // Print second row
        System.out.println();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 9 ||
            i == 12 || i == 14 || i == 17 ||
            i == 19 || i == 22 || i == 24 || 
            i == 27)
                System.out.print(ch);
            else
                System.out.print(" ");
        }
      
        // Print third row
        System.out.println();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 5 || i == 6 ||
            i == 7 || i == 9 || i == 10 || 
            i == 11 || i == 12 || i == 14 || 
            i == 15 || i == 16 || i == 17 || 
            i == 19 || i == 20 || i == 21 || 
            i == 22 || i == 25 || i == 26)
                System.out.print(ch);
            else
                System.out.print(" ");
        }
      
        // Print fourth row
        System.out.println();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 9 || 
            i == 12 || i == 14 || i == 19 || 
            i == 25 || i == 26)
                System.out.print(ch);
            else
                System.out.print(" ");
        }
      
        // print fifth row
        System.out.println();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 9 || i == 12 ||
            i == 14 || i == 19 || i == 25 || i == 26)
                System.out.print(ch);
            else
                System.out.print(" ");
        }
      
        // Happy is printed, now print
        // Holi row by row
        System.out.println();
        System.out.println();
        System.out.println();
      
        // Print first row
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 10 || i == 11 || 
            i == 14 || i == 19 || i == 20 || i == 21 || 
            i == 22)
                System.out.print(ch);
            else
                System.out.print(" ");
        }
      
        // Print second row
        System.out.println();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 9 || i == 12 ||
            i == 14 || i == 20 || i == 21)
                System.out.print(ch);
            else
                System.out.print(" ");
        }
      
        // Print third row
        System.out.println();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 5 || i == 6 || i == 7 ||
            i == 9 || i == 12 || i == 14 || i == 20 || 
            i == 21)
                System.out.print(ch);
            else
                System.out.print(" ");
        }
      
        // Print fourth row
        System.out.println();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 9 || i == 12 || 
            i == 14 || i == 20 || i == 21)
                System.out.print(ch);
            else
                System.out.print(" ");
        }
      
        // Print fifth row
        System.out.println();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 10 || i == 11 || 
            i == 14 || i == 15 || i == 16 || i == 17 || 
            i == 19 || i == 20 || i == 21 || i == 22)
                System.out.print(ch);
            else
                System.out.print (" ");
        }
      
      
          
          
    }
}
  
// This code is contributed by vt_m.

Python3




# Python3 program to print Happy Holi
  
# Print first row
# You can choose any char
ch = '@'
for i in range(1, 35): 
        if (i == 4 or i == 7 or i == 10 or
            i == 11 or i == 14 or i == 15 or
            i == 16 or i == 17 or i == 19 or
            i == 20 or i == 21 or i == 22 or
            i == 24 or i == 27):
            print(ch, end = "")
        else:
            print(end = " ")
print()
  
# Print second row
for i in range(1, 35):
    if (i == 4 or i == 7 or i == 9 or
        i == 12 or i == 14 or i == 17 or
        i == 19 or i == 22 or i == 24 or i == 27):
        print(ch, end = "")
    else:
        print(end = " ")
print() 
  
# Print third row
for i in range(1, 35):
    if (i == 4 or i == 5 or i == 6 or
        i == 7 or i == 9 or i == 10 or
        i == 11 or i == 12 or i == 14 or
        i == 15 or i == 16 or i == 17 or
        i == 19 or i == 20 or i == 21 or
        i == 22 or i == 25 or i == 26):
        print(ch, end = "")
    else:
        print(end = " "
print()
  
# Print fourth row
for i in range(1, 35):
    if (i == 4 or i == 7 or i == 9 or
        i == 12 or i == 14 or i == 19 or
        i == 25 or i == 26):
        print(ch, end = "")
    else:
        print(end = " ")
print() 
  
# Print fifth row
for i in range(1, 35):
    if (i == 4 or i == 7 or i == 9 or
        i == 12 or i == 14 or i == 19 or
        i == 25 or i == 26):
        print(ch, end = "")
    else:
        print(end = " ")
print() 
  
# Happy is printed, now print
# Holi row by row
print()
print()
  
# Print first row
for i in range(1, 35):
    if (i == 4 or i == 7 or i == 10 or 
        i == 11 or i == 14 or i == 19 or
        i == 20 or i == 21 or i == 22):
        print(ch, end = "")
    else:
        print(end = " ")
print() 
  
# Print second row
for i in range(1, 35):
    if (i == 4 or i == 7 or i == 9 or 
        i == 12 or i == 14 or i == 20
        or i == 21):
        print(ch, end = "")
    else:
        print(end = " ")
print() 
  
# Print third row
for i in range(1, 35):
    if (i == 4 or i == 5 or i == 6 or
        i == 7 or i == 9 or i == 12 or
        i == 14 or i == 20 or i == 21):
        print(ch, end = "")
    else:
        print(end = " ")
print() 
  
# Print fourth row
for i in range(1, 35):
    if (i == 4 or i == 7 or i == 9 or
        i == 12 or i == 14 or i == 20
        or i == 21):
        print(ch, end = "")
    else:
        print(end = " ")
print() 
  
# Print fifth row
for i in range(1, 35):
    if (i == 4 or i == 7 or i == 10 or i == 11 or
        i == 14 or i == 15 or i == 16 or i == 17 or
        i == 19 or i == 20 or i == 21 or i == 22):
        print(ch, end = "")
    else:
        print(end = " ")
  
# This code is contributed by Azkia Anam.

C#




// C# program to print Happy Holi
using System;
  
class GFG 
{
      
    // Driver Code
    public static void Main (String[] args) 
    {
        // Print first row
        // You can choose any char
        char ch = '@';
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 10 || 
            i == 11 || i == 14 || i == 15 || 
            i == 16 || i == 17 || i == 19 || 
            i == 20 || i == 21 || i == 22 || 
            i == 24 || i == 27)
                Console.Write(ch);
            else
                Console.Write(" ");
        }
      
        // Print second row
        Console.WriteLine();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 9 ||
            i == 12 || i == 14 || i == 17 ||
            i == 19 || i == 22 || i == 24 || 
            i == 27)
                Console.Write(ch);
            else
                Console.Write(" ");
        }
      
        // Print third row
        Console.WriteLine();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 5 || i == 6 ||
            i == 7 || i == 9 || i == 10 || 
            i == 11 || i == 12 || i == 14 || 
            i == 15 || i == 16 || i == 17 || 
            i == 19 || i == 20 || i == 21 || 
            i == 22 || i == 25 || i == 26)
                Console.Write(ch);
            else
                Console.Write(" ");
        }
      
        // Print fourth row
        Console.WriteLine();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 9 || 
            i == 12 || i == 14 || i == 19 || 
            i == 25 || i == 26)
                Console.Write(ch);
            else
                Console.Write(" ");
        }
      
        // print fifth row
        Console.WriteLine();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 9 || i == 12 ||
            i == 14 || i == 19 || i == 25 || i == 26)
                Console.Write(ch);
            else
                Console.Write(" ");
        }
      
        // Happy is printed, now print
        // Holi row by row
        Console.WriteLine();
        Console.WriteLine();
        Console.WriteLine();
      
        // Print first row
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 10 || i == 11 || 
            i == 14 || i == 19 || i == 20 || i == 21 || 
            i == 22)
                Console.Write(ch);
            else
                Console.Write(" ");
        }
      
        // Print second row
        Console.WriteLine();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 9 || i == 12 ||
            i == 14 || i == 20 || i == 21)
                Console.Write(ch);
            else
                Console.Write(" ");
        }
      
        // Print third row
        Console.WriteLine();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 5 || i == 6 || i == 7 ||
            i == 9 || i == 12 || i == 14 || i == 20 || 
            i == 21)
                Console.Write(ch);
            else
                Console.Write(" ");
        }
      
        // Print fourth row
        Console.WriteLine();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 9 || i == 12 || 
            i == 14 || i == 20 || i == 21)
                Console.Write(ch);
            else
                Console.Write(" ");
        }
      
        // Print fifth row
        Console.WriteLine();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 10 || i == 11 || 
            i == 14 || i == 15 || i == 16 || i == 17 || 
            i == 19 || i == 20 || i == 21 || i == 22)
                Console.Write(ch);
            else
                Console.Write(" ");
        }
      
      
          
          
    }
}
  
// This code is contributed by parashar....

PHP




<?php
// PHP program to 
// print Happy Holi
  
// Print first row
// You can choose any char
$ch = '@';
for ($i = 1; $i <= 34; $i++) 
{
    if ($i == 4 || $i == 7 || 
        $i == 10 || $i == 11 || 
        $i == 14 || $i == 15 || 
        $i == 16 || $i == 17 || 
        $i == 19 || $i == 20 || 
        $i == 21 || $i == 22 || 
        $i == 24 || $i == 27)
        echo ($ch);
    else
        echo (" ");
}
  
// Print second row
echo ("\n");
for ($i = 1; $i <= 34; $i++) 
{
    if ($i == 4 || $i == 7 ||
        $i == 9 || $i == 12 || 
        $i == 14 || $i == 17 ||
        $i == 19 || $i == 22 || 
        $i == 24 || $i == 27)
        echo ($ch);
    else
        echo (" ");
}
  
// Print third row
echo ("\n");
for ($i = 1; $i <= 34; $i++) 
{
    if ($i == 4 || $i == 5 ||
        $i == 6 || $i == 7 ||
        $i == 9 || $i == 10 || 
        $i == 11 || $i == 12 ||
        $i == 14 || $i == 15 || 
        $i == 16 || $i == 17 || 
        $i == 19 || $i == 20 || 
        $i == 21 || $i == 22 || 
        $i == 25 || $i == 26)
        echo ($ch);
    else
        echo (" ");
}
  
// Print fourth row
echo ("\n");
for ($i = 1; $i <= 34; $i++) 
{
    if ($i == 4 || $i == 7 || $i == 9 || 
    $i == 12 || $i == 14 || $i == 19 || 
    $i == 25 || $i == 26)
        echo ($ch);
    else
        echo (" ");
}
  
// Print fifth row
echo ("\n");
for ($i = 1; $i <= 34; $i++) 
{
    if ($i == 4 || $i == 7 || 
        $i == 9 || $i == 12 ||
        $i == 14 || $i == 19 || 
        $i == 25 || $i == 26)
        echo ($ch);
    else
        echo (" ");
}
  
// Happy is printed, 
// now print
// Holi row by row
echo ("\n");
echo ("\n");
echo ("\n");
  
// Print First row
for ($i = 1; $i <= 34; $i++) 
{
    if ($i == 4 || $i == 7 || 
        $i == 10 || $i == 11 || 
        $i == 14 || $i == 19 || 
        $i == 20 || $i == 21 || 
        $i == 22)
        echo ($ch);
    else
        echo (" ");
}
  
// Print second row
echo ("\n");
for ($i = 1; $i <= 34; $i++) 
{
    if ($i == 4 || $i == 7 || 
        $i == 9 || $i == 12 ||
        $i == 14 || $i == 20 || 
        $i == 21)
        echo ($ch);
    else
        echo (" ");
}
  
// Print Third row
echo ("\n");
for ($i = 1; $i <= 34; $i++) 
{
    if ($i == 4 || $i == 5 || 
        $i == 6 || $i == 7 ||
        $i == 9 || $i == 12 || 
        $i == 14 || $i == 20 || 
        $i == 21)
        echo ($ch);
    else
        echo (" ");
}
  
// Print fourth row
echo ("\n");
for ($i = 1; $i <= 34; $i++) 
{
    if ($i == 4 || $i == 7 ||
        $i == 9 || $i == 12 || 
        $i == 14 || $i == 20 ||
        $i == 21)
        echo ($ch);
    else
        echo (" ");
}
  
// Print fifth row
echo ("\n");
for ($i = 1; $i <= 34; $i++)
{
    if ($i == 4 || $i == 7 ||
        $i == 10 || $i == 11 || 
        $i == 14 || $i == 15 || 
        $i == 16 || $i == 17 || 
        $i == 19 || $i == 20 || 
        $i == 21 || $i == 22)
        echo ($ch);
    else
        echo (" ");
}
  
// This code is contributed by 
// Manish Shaw(manishshaw1)
?>


Output:
   @  @  @@  @@@@ @@@@ @  @       
   @  @ @  @ @  @ @  @ @  @       
   @@@@ @@@@ @@@@ @@@@  @@        
   @  @ @  @ @    @     @@        
   @  @ @  @ @    @     @@        


   @  @  @@  @    @@@@            
   @  @ @  @ @     @@             
   @@@@ @  @ @     @@             
   @  @ @  @ @     @@             
   @  @  @@  @@@@ @@@@            


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!