Skip to content

Instantly share code, notes, and snippets.

@thecoducer
Last active August 25, 2017 11:55
Show Gist options
  • Save thecoducer/227cab1e71bd894a6e5c068806cdae2f to your computer and use it in GitHub Desktop.
Save thecoducer/227cab1e71bd894a6e5c068806cdae2f to your computer and use it in GitHub Desktop.
/**
Author:- Mayukh Datta
**/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define H 7
#define W 8 //one extra room in the char array is required for storing '\0'
void main()
{
char num[11]; //here too one extra room is needed for the '\0'
char c; //for option
int i, j, k;
//declaring char 2D arrays and initializing with hash-printed digits
char zero[H][W]={" ##### ", //H=0
" # # ", //H=1
" # # ", //H=2
" # # ", //H=3
" # # ", //H=4
" # # ", //H=5
" ##### "},//H=6
one[H][W]={" # ",
" ## ",
" # ",
" # ",
" # ",
" # ",
" ##### "},
two[H][W]={" ##### ",
" # ",
" # ",
" ##### ",
" # ",
" # ",
" ##### "},
three[H][W]={" ##### ",
" # ",
" # ",
" ##### ",
" # ",
" # ",
" ##### "},
four[H][W]={" # ",
" # # ",
" # # ",
" ##### ",
" # ",
" # ",
" # "},
five[H][W]={" ##### ",
" # ",
" # ",
" ##### ",
" # ",
" # ",
" ##### "},
six[H][W]={" ##### ",
" # ",
" # ",
" ##### ",
" # # ",
" # # ",
" ##### "},
seven[H][W]={" ##### ",
" # ",
" # ",
" #### ",
" # ",
" # ",
" # "},
eight[H][W]={" ##### ",
" # # ",
" # # ",
" ##### ",
" # # ",
" # # ",
" ##### "},
nine[H][W]={" ##### ",
" # # ",
" # # ",
" ##### ",
" # ",
" # ",
" # "};
do
{
printf("Enter a number upto 10 digits:- ");
fflush(stdin);
gets(num);
if(strlen(num)>10)
printf("\nYou must enter a number upto 10 digits.\nTry again!\n");
else
{
printf("\n");
k=1;
j=0; //controls H of each digit
while(k<=7) //controls height
{
for(i=0;i<strlen(num);i++) //reads each digit
{
if(num[i]=='0')
printf("%s", zero[j]);
else if(num[i]=='1')
printf("%s", one[j]);
else if(num[i]=='2')
printf("%s", two[j]);
else if(num[i]=='3')
printf("%s", three[j]);
else if(num[i]=='4')
printf("%s", four[j]);
else if(num[i]=='5')
printf("%s", five[j]);
else if(num[i]=='6')
printf("%s", six[j]);
else if(num[i]=='7')
printf("%s", seven[j]);
else if(num[i]=='8')
printf("%s", eight[j]);
else if(num[i]=='9')
printf("%s", nine[j]);
}
printf("\n");
k++;
j++;
}
}
printf("\nEnter Y to continue:- ");
fflush(stdin);
scanf("%c", &c);
}while(c=='Y'||c=='y');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment