Open In App

Print Happy New Year 2024

Last Updated : 11 Jan, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Write a program to print “HAPPY NEW YEAR 2024” pattern.

Approach to print Happy New Year 2024:

Here are step-by-step instructions to create a program that prints “HAPPY NEW YEAR 2024” in a pattern:

  1. Set up your development environment: Ensure that you have a compiler installed on your machine. You can use an integrated development environment (IDE) like GeeksforGeeks IDE.
  2. Create a new source file: Create a new source file. For example, you can create a file named NewYearPattern.
  3. Define functions for each word: Define separate functions for each word (“HAPPY,” “NEW,” “YEAR,” and “2024”). Each function should print the corresponding pattern.
  4. Implement the pattern for each word: Fill in the code within each function to print the desired pattern for each word. Use arrays or strings to represent the patterns.
  5. Call the functions in the main function: In the main function, call each of the functions to print the patterns for “HAPPY,” “NEW,” “YEAR,” and “2024.”
  6. Compile and run the program: Compile the program using your compiler and run the executable. Ensure that the output displays the desired patterns for each word.

Adjust the patterns or add more customization as needed.

Program to print HAPPY NEW YEAR 2024:

C++




#include <iostream>
 
void printHappyPattern() {
    const char* happyPattern[] = {
        "H   H  AAAAA  PPPP  PPPP  Y   Y",
        "H   H  A   A  P   P P   P  Y Y ",
        "HHHHH  AAAAA  PPPP  PPPP    Y  ",
        "H   H  A   A  P     P       Y  ",
        "H   H  A   A  P     P       Y  "
    };
 
    // Print the pattern for "HAPPY"
    for (const char* line : happyPattern) {
        std::cout << line << "\n";
    }
}
 
void printNewPattern() {
    const char* newPattern[] = {
        "N   N  EEEEE  W   W",
        "NN  N  E      W   W",
        "N N N  EEEE   W W W",
        "N  NN  E      W W W",
        "N   N  EEEEE  W   W"
    };
 
    // Print the pattern for "NEW"
    for (const char* line : newPattern) {
        std::cout << line << "\n";
    }
}
 
void printYearPattern() {
    const char* yearPattern[] = {
        "Y   Y  EEEEE  AAAAA  RRRR ",
        " Y Y   E      A   A  R   R",
        "  Y    EEEE   AAAAA  RRRR ",
        "  Y    E      A   A  R  R ",
        "  Y    EEEEE  A   A  R   RR"
    };
 
    // Print the pattern for "YEAR"
    for (const char* line : yearPattern) {
        std::cout << line << "\n";
    }
}
 
void print2024Pattern() {
    const char* pattern2024[] = {
        "  222    000    222     44 ",
        " 2   2  0   0  2   2   4 4",
        "    2   0   0     2   44444",
        "   2    0   0    2       4",
        "  2222   000    2222     4"
    };
 
    // Print the pattern for "2024"
    for (const char* line : pattern2024) {
        std::cout << line << "\n";
    }
}
 
int main() {
    // Call the functions to print the patterns for each word
    printHappyPattern();
    std::cout << "\n";  // Add a newline for separation
    printNewPattern();
    std::cout << "\n";
    printYearPattern();
    std::cout << "\n";
    print2024Pattern();
 
    return 0;
}


C




#include <stdio.h>
 
void printHappyPattern() {
    const char* happyPattern[] = {
        "H   H  AAAAA  PPPP  PPPP  Y   Y",
        "H   H  A   A  P   P P   P  Y Y ",
        "HHHHH  AAAAA  PPPP  PPPP    Y  ",
        "H   H  A   A  P     P       Y  ",
        "H   H  A   A  P     P       Y  "
    };
 
    // Print the pattern for "HAPPY"
    for (int i = 0; i < 5; i++) {
        printf("%s\n", happyPattern[i]);
    }
}
 
void printNewPattern() {
    const char* newPattern[] = {
        "N   N  EEEEE  W   W",
        "NN  N  E      W   W",
        "N N N  EEEE   W W W",
        "N  NN  E      W W W",
        "N   N  EEEEE  W   W"
    };
 
    // Print the pattern for "NEW"
    for (int i = 0; i < 5; i++) {
        printf("%s\n", newPattern[i]);
    }
}
 
void printYearPattern() {
    const char* yearPattern[] = {
        "Y   Y  EEEEE  AAAAA  RRRR ",
        " Y Y   E      A   A  R   R",
        "  Y    EEEE   AAAAA  RRRR ",
        "  Y    E      A   A  R  R ",
        "  Y    EEEEE  A   A  R   RR"
    };
 
    // Print the pattern for "YEAR"
    for (int i = 0; i < 5; i++) {
        printf("%s\n", yearPattern[i]);
    }
}
 
void print2024Pattern() {
    const char* pattern2024[] = {
        "  222    000    222     44 ",
        " 2   2  0   0  2   2   4 4",
        "    2   0   0     2   44444",
        "   2    0   0    2       4",
        "  2222   000    2222     4"
    };
 
    // Print the pattern for "2024"
    for (int i = 0; i < 5; i++) {
        printf("%s\n", pattern2024[i]);
    }
}
 
int main() {
    // Call the functions to print the patterns for each word
    printHappyPattern();
    printf("\n");  // Add a newline for separation
    printNewPattern();
    printf("\n");
    printYearPattern();
    printf("\n");
    print2024Pattern();
 
    return 0;
}


Java




public class NewYearPattern {
    public static void printNewPattern() {
        String[] newPattern = {
            "N   N  EEEEE  W   W",
            "NN  N  E      W   W",
            "N N N  EEEE   W W W",
            "N  NN  E      W W W",
            "N   N  EEEEE  W   W"
        };
 
        // Print the pattern for "NEW"
        for (String line : newPattern) {
            System.out.println(line);
        }
    }
 
    public static void printYearPattern() {
        String[] yearPattern = {
            "Y   Y  EEEEE  AAAAA  RRRR ",
            " Y Y   E      A   A  R   R",
            "  Y    EEEE   AAAAA  RRRR ",
            "  Y    E      A   A  R  R ",
            "  Y    EEEEE  A   A  R   RR"
        };
 
        // Print the pattern for "YEAR"
        for (String line : yearPattern) {
            System.out.println(line);
        }
    }
 
    public static void print2024Pattern() {
        String[] pattern2024 = {
        222    000    222     44 ",
        " 2   2  0   0  2   2   4 4",
        "    2   0   0     2   44444",
        "   2    0   0    2       4",
        2222   000    2222     4"
        };
 
        // Print the pattern for "2024"
        for (String line : pattern2024) {
            System.out.println(line);
        }
    }
 
    public static void main(String[] args) {
        // Call the functions to print the patterns for each word
        printNewPattern();
        System.out.println();  // Add a newline for separation
        printYearPattern();
        System.out.println();
        print2024Pattern();
    }
}


Python3




def print_new_pattern():
    new_pattern = [
        "N   N  EEEEE  W   W",
        "NN  N  E      W   W",
        "N N N  EEEE   W W W",
        "N  NN  E      W W W",
        "N   N  EEEEE  W   W"
    ]
 
    # Print the pattern for "NEW"
    for line in new_pattern:
        print(line)
 
def print_year_pattern():
    year_pattern = [
        "Y   Y  EEEEE  AAAAA  RRRR ",
        " Y Y   E      A   A  R   R",
        "  Y    EEEE   AAAAA  RRRR ",
        "  Y    E      A   A  R  R ",
        "  Y    EEEEE  A   A  R   RR"
    ]
 
    # Print the pattern for "YEAR"
    for line in year_pattern:
        print(line)
 
def print_2024_pattern():
    pattern_2024 = [
        222    000    222     44 ",
        " 2   2  0   0  2   2   4 4",
        "    2   0   0     2   44444",
        "   2    0   0    2       4",
        2222   000    2222     4"
    ]
 
    # Print the pattern for "2024"
    for line in pattern_2024:
        print(line)
 
# Call the functions to print the patterns for each word
print_new_pattern()
print()  # Add a newline for separation
print_year_pattern()
print()
print_2024_pattern()


C#




using System;
 
class Program
{
    static void PrintHappyPattern()
    {
        string[] happyPattern =
        {
            "H   H  AAAAA  PPPP  PPPP  Y   Y",
            "H   H  A   A  P   P P   P  Y Y ",
            "HHHHH  AAAAA  PPPP  PPPP    Y  ",
            "H   H  A   A  P     P       Y  ",
            "H   H  A   A  P     P       Y  "
        };
 
        // Print the pattern for "HAPPY"
        foreach (string line in happyPattern)
        {
            Console.WriteLine(line);
        }
    }
 
    static void PrintNewPattern()
    {
        string[] newPattern =
        {
            "N   N  EEEEE  W   W",
            "NN  N  E      W   W",
            "N N N  EEEE   W W W",
            "N  NN  E      W W W",
            "N   N  EEEEE  W   W"
        };
 
        // Print the pattern for "NEW"
        foreach (string line in newPattern)
        {
            Console.WriteLine(line);
        }
    }
 
    static void PrintYearPattern()
    {
        string[] yearPattern =
        {
            "Y   Y  EEEEE  AAAAA  RRRR ",
            " Y Y   E      A   A  R   R",
            "  Y    EEEE   AAAAA  RRRR ",
            "  Y    E      A   A  R  R ",
            "  Y    EEEEE  A   A  R   RR"
        };
 
        // Print the pattern for "YEAR"
        foreach (string line in yearPattern)
        {
            Console.WriteLine(line);
        }
    }
 
    static void Print2024Pattern()
    {
        string[] pattern2024 =
        {
            "  222    000    222     44 ",
            " 2   2  0   0  2   2   4 4",
            "    2   0   0     2   44444",
            "   2    0   0    2       4",
            "  2222   000    2222     4"
        };
 
        // Print the pattern for "2024"
        foreach (string line in pattern2024)
        {
            Console.WriteLine(line);
        }
    }
 
    static void Main()
    {
        // Call the functions to print the patterns for each word
        PrintHappyPattern();
        Console.WriteLine();  // Add a newline for separation
        PrintNewPattern();
        Console.WriteLine();
        PrintYearPattern();
        Console.WriteLine();
        Print2024Pattern();
    }
}


Javascript




function printNewPattern() {
    const newPattern = [
        "N   N  EEEEE  W   W",
        "NN  N  E      W   W",
        "N N N  EEEE   W W W",
        "N  NN  E      W W W",
        "N   N  EEEEE  W   W"
    ];
 
    // Print the pattern for "NEW"
    for (const line of newPattern) {
        console.log(line);
    }
}
 
function printYearPattern() {
    const yearPattern = [
        "Y   Y  EEEEE  AAAAA  RRRR ",
        " Y Y   E      A   A  R   R",
        "  Y    EEEE   AAAAA  RRRR ",
        "  Y    E      A   A  R  R ",
        "  Y    EEEEE  A   A  R   RR"
    ];
 
    // Print the pattern for "YEAR"
    for (const line of yearPattern) {
        console.log(line);
    }
}
 
function print2024Pattern() {
    const pattern2024 = [
        "  222    000    222     44 ",
        " 2   2  0   0  2   2   4 4",
        "    2   0   0     2   44444",
        "   2    0   0    2       4",
        "  2222   000    2222     4"
    ];
 
    // Print the pattern for "2024"
    for (const line of pattern2024) {
        console.log(line);
    }
}
 
// Call the functions to print the patterns for each word
printNewPattern();
console.log();  // Add a newline for separation
printYearPattern();
console.log();
print2024Pattern();


Output (Happy New Year 2024):

HAPPY-NEW-YEAR-2024

Print Happy New Year 2024



Similar Reads

Program to print the number of days in a given year
Write a program to print the number of days in a given year. Examples: Input: 2023Output: 365Explanation: The year 2023 is not a leap year, therefore the number of days are 365. Input: 2024Output: 366Explanation: The year 2024 is a leap year, therefore the number of days are 366. Approach: To solve the problem, follow the below idea: To determine t
4 min read
Write a Program to Print 2024 Calendar
Write a Program to print the 2024 Calendar. Example: 2024 Calendar: January 2024 Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 February 2024 Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 March 2024 Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 1
17 min read
Write a Program to Print Holiday Calendar 2024
Write a program to print the Holiday Calendar 2024. Output Format (Holiday Calendar 2024): January 26 - Friday - Republic DayMarch 25 - Monday - HoliMarch 29 - Friday - Good FridayApril 11 - Thursday - Id-ul-FitrApril 17 - Wednesday - Ram NavmiApril 21 - Sunday - Mahavir JayantiMay 23 - Thursday - Buddha PurnimaJune 17 - Monday - Id-ul-Zuha (Bakrid
5 min read
Program to Print the Trapezium Pattern
Given 'num' which indicates number of lines.The task is to print a trapezium pattern in num lines.Examples: Input : 4 Output : 1*2*3*4*17*18*19*20 5*6*7*14*15*16 8*9*12*13 10*11 Input : 2 Output : 1*2*5*6 3*4 Algorithm : step 1. To read num which indicates the number of lines. step 2.We are diving the pattern into 2 halves that is LHS part and the
6 min read
Recursive program to print triangular patterns
We have discussed iterative pattern printing in previous post. Examples: Input : 7 Output : * * * * * * * * * * * * * * * * * * * * * * * * * * * * Algorithm:- step 1:- first think for the base condition i.e. number less than 0 step 2:-do the recursive calls till number less than 0 i.e:- printPartten(n-1, k+1); step 3:-print the spaces step 4:-then
8 min read
Program to print Hut
Given a number N, the task is to print Hut of width n. [caption width="800"]Output[/caption] Algorithm: Take input for the width of the hut (n).If n is even, increment it by 1.Loop through rows from 0 to n - n/3.Loop through columns from 0 to n.Determine the character to print based on the position of the row and column: a. If the position is on th
9 min read
Can we write a print statement within if parentheses?
If-Else is a decision-making statement, where the result will be either true or false. If the statement accepts boolean values – if the value is true then it will execute the block of statements below it otherwise not. If no curly braces '{' and '}' is provides after if(condition) then by default if statement will consider the immediately below sta
1 min read
Program to print first 10 perfect squares
Write a program to print the first 10 perfect squares. A perfect square is an integer which is the square of some other integer, or we can say that it is a second exponent of an integer. Output format: 1 4 9 16 25 .... Approach: We know that the first 10 perfect squares will be square of 1, square of 2, square of 3... till square of 10. So, iterate
2 min read
Program to Print Inverted Left Half Pyramid Pattern (Star Pattern)
Given an integer N, the task is is to print a left half pyramid pattern with N rows. In this pattern, the first row contains N stars, the second row contains N - 1 stars, and so forth until the Nth row, which contains only 1 star. All the stars are aligned to the right. Examples: Input: 3Output: *** ** * Input: 5Output: ***** **** *** ** * Approach
4 min read
Program to Print Inverted Right Half Pyramid Pattern (Star Pattern)
Given an integer N, print N rows of inverted right half pyramid pattern. In inverted right half pattern of N rows, the first row has N number of stars, second row has (N - 1) number of stars and so on till the Nth row which has only 1 star. Examples: Input: n = 5Output:*************** Input: n = 3Output:****** Approach: The problem can be solved us
3 min read
Article Tags :