
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Program to print ‘N’ alphabet using the number pattern from 1 to n in C++
In this tutorial, we will be discussing a program to print ‘N’ alphabet using the number pattern from 1 to n.
For this we will have to print the english alphabet N. Our task is to determine the size of the letter and print it back using the numbers from 1 to n.
Example
#include <iostream> using namespace std; //printing the letter N void print_N(int N){ int index, side_index, size; int Right = 1, Left = 1, Diagonal = 2; for (index = 0; index < N; index++) { cout << Left++; for (side_index = 0; side_index < 2 * (index); side_index++) cout << " "; if (index != 0 && index != N - 1) cout << Diagonal++; else cout << " "; for (side_index = 0; side_index < 2 * (N - index - 1); side_index++) cout << " "; cout << Right++; cout << endl; } } int main(int argc, char** argv){ int Size = 8; print_N(Size); return 0; }
Output
1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 7 7 7 8 8
- Related Questions & Answers
- Python Program to print the pattern ‘G’
- C Program to print numbers from 1 to N without using semicolon
- Python program to print a checkboard pattern of n*n using numpy.
- Python program to print check board pattern of n*n using numpy
- Python program to replace first ‘K’ elements by ‘N’
- Print n x n spiral matrix using O(1) extra space in C Program.
- Python Program to Read a Number n And Print the Series "1+2+…..+n= "
- Goland Program to Read a Number (n) And Print the Series "1+2+…..+n= "
- Python Program to Read a Number n and Print the Natural Numbers Summation Pattern
- Golang Program to Read a Number (n) and Print the Natural Numbers Summation Pattern
- Program to find duplicate element from n+1 numbers ranging from 1 to n in Python
- Program to print number pattern in C
- Find the number of integers from 1 to n which contains digits 0’s and 1’s only in C++
- Write a program in C++ to count the Number of substrings that starts with ‘1’ and ends with ‘1’
- Print prime numbers from 1 to N in reverse order
Advertisements