
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
C++ program to Zoom digits of an integer
In this program we will see how to zoom digits of an integer in C++. The Zooming means print the numbers using some other characters in bigger form. The logic is simple, but we have to create larger numbers one by one from 0 to 9.
Example Code
#include <bits/stdc++.h> using namespace std; void print_zero() { for (int i=0; i<5; i++) { for (int j=0; j<5; j++) { if (i==0 || i==4) cout << '#'; else if (j==0 || j==4) cout << '#'; else cout << " "; } cout << endl; } } void print_one() { for (int i=0; i<5; i++) { for (int j=0; j<5; j++) { if (j==2) cout << '#'; else if ((i==1 && j==1)) cout << '#'; else if (i==4) cout << '#'; else cout << " "; } cout << endl; } } void print_two() { for (int i=0; i<5; i++) { for (int j=0; j<4; j++) { if (i==0 && j==4) cout << " "; else if (i==0 || i==4) cout << '#'; else if (i==1 && j==0) cout << '#'; else if (i==(4-j)) cout << '#'; else cout << " "; } cout << endl; } } void print_three() { for (int i=0; i<5; i++) { for (int j=0; j<5; j++) { if (i==0 || i==2 || i==4) cout << '#'; else if (j==4) cout << '#'; else cout << " "; } cout << endl; } } void print_four() { for (int i=0; i<5; i++) { for (int j=0; j<5; j++) { if (j==4) cout << '#'; else if (i==2) cout << '#'; else if (j==0 && (i==0 || i==1)) cout << '#'; else cout << " "; } cout << endl; } } void print_five() { for (int i=0; i<5; i++) { for (int j=0; j<5; j++) { if (i==0 || i==2 || i==4) cout << '#'; else if ((j==0 && i==1) || (j==4 && i==3)) cout << '#'; else cout << " "; } cout << endl; } } void print_six() { for (int i=0; i<5; i++) { for (int j=0; j<5; j++) { if (i==0 || i==2 || i==4) cout << '#'; else if ((j==0 && (i==1 || i==3)) || (j==4 && i==3)) cout << '#'; else cout << " "; } cout << endl; } } void print_seven() { for (int i=0 ; i<5; i++) { for (int j=0 ; j<5; j++) { if (i==0 && (j!=4)) cout << '#'; else if (i==2 && (j==2 || j==4)) cout << '#'; else if (j==3) cout << '#'; else cout << " "; } cout << endl; } } void print_eight() { for (int i=0; i<5; i++) { for (int j=0; j<5; j++) { if (i==0 || i==2 || i==4) cout << '#'; else if ((j==0 && (i==1 || i==3) || (j==4 && (i==1 || i==3)))) cout << '#'; else cout << " "; } cout << endl; } } void print_nine() { for (int i=0; i<5; i++) { for (int j=0; j<5; j++) { if ( i==0 || i==2 || j==4) cout << '#'; else if (i==1 && j==0) cout << '#'; else cout << " "; } cout << endl; } } void zoom_digit(int number) { // Converting number to string stringstream ss; ss << number; string str = ss.str(); for (int k=0; k<str.length(); k++) { cout << endl; switch(str[k]-'0'){ case 0: print_zero(); continue; case 1: print_one(); continue; case 2: print_two(); continue; case 3: print_three(); continue; case 4: print_four(); continue; case 5: print_five(); continue; case 6: print_six(); continue; case 7: print_seven(); continue; case 8: print_eight(); continue; case 9: print_nine(); continue; } } } int main() { long long number = 125478539; zoom_digit(number); }
Output
- Related Articles
- Java Program to Count Number of Digits in an Integer
- Swift Program to Count Number of Digits in an Integer
- Haskell Program to Count Number of Digits in an Integer
- Kotlin Program to Count Number of Digits in an Integer
- Python program to find the sum of all even and odd digits of an integer list
- Java program to Count the number of digits in a given integer
- Subtract the Product and Sum of Digits of an Integer in C++
- Java Program to Print an Integer
- Kotlin Program to Print an Integer
- Count even and odd digits in an Integer in C++
- Reverse digits of an integer in JavaScript without using array or string methods
- Java Program to extend the size of an Integer array
- Python Program to Find the Smallest Divisor of an Integer
- Golang Program to Find the Smallest Divisor of an Integer
- Golang Program to Generate all the Divisors of an Integer

Advertisements