Welcome To BestPunjab

We Are Re-Constructing




#include < stdio.h >
#include < stdlib.h >
#include < conio.h >
#include < windows.h >

void gotoxy(int x, int y) 
{
    COORD coord;
    coord.X = x;
    coord.Y = y;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
void clear(int spaces)
{
	int i;
	for(i=1;i<=spaces;i++)
	{
		putch(' ');
	}
}
void main()
{
	char str[15];
	char ch;
	int c, i, length, num;
	system("cls");
	gotoxy(40,10);
	printf("Amount : ");
	gotoxy(50,10);
	printf("\033[7m");
	clear(15);
	printf("\033[0m\n");
	gotoxy(50,10);
	printf("\033[7m");
	c=0;
	while(1)
	{
		ch=getch();
		if(ch=='\n' || ch=='\r' || ch==27)
		{
			break;
		}
		if(ch==8 && c>0)
		{
			c--;
			str[c]='\0';
			gotoxy(50,10);
			clear(15);
			length=strlen(str);
			gotoxy(65-length, 10);
			printf("%s",str);
		}
		if(ch>='0' && ch<='9')
		{
			str[c]=ch;
			c++;
			str[c]='\0';
			gotoxy(50,10);
			clear(15);
			length=strlen(str);
			gotoxy(65-length, 10);
			printf("%s",str);
		}
	}
	num=atoi(str);
	printf("\033[0m\n");
	printf("Number = %d\n",num);
	
}