adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Program in C to move a word

Program in C to move a word

#include<stdio.h>
#include<windows.h>
#include<conio.h>
 void gotoxy(int x, int y)           //definition of gotoxy function//
    {
     COORD pos ={x,y};
     SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
   }
 int main()
  {
     int b,c,i,x=20,y=20;
     char a;
     printf("Press a for Left\nPress d for Right\nPress w for Up\nPress z for Down\nPress x for exit");
     printf("\nPress any key to continue!");
     getch();
     gotoxy(x,y);
     printf("Programming.OM");
     while(a!='x')
     {
         a=getch();
         switch(a)
           {
                case 'z':y++;
                        break;
                case 'w':y--;
                        break;
                case 'd':x++;
                        break;
                case 'a':x--;
                        break;
           }
           system("cls");
           gotoxy(x,y);
           printf("Programming.OM");
     }
    getch();
  }
Output :-






Post a Comment

0 Comments