C Program: A Simple Use of gotoxy() to Display Hindi Text

CWC
3 Min Read

C Program: A Simple Use of gotoxy() to Display Hindi Text

Gotoxy () function is used in programs to make the cursor move to different positions as it is on a graph, as it divides the output screen into a graph with x and y coordinates and as the user gives both x and y coordinates in the function gotoxy() the pointer move to that location and print accordingly.

We begin our code by including the header files “stdio.h”, “conio.h” and “dos.h”

#include<stdio.h>
#include<conio.h>
#include<dos.h>
void main()
{

After including the header files a simple message will be displayed on the output screen saying “look at this” which makes the user to concentrate on the text coming up next and this quote vanishes after 2 secs as “delay” function is used

int i,j,k;
 clrscr();
 printf("LOOK AT THIS:");
 delay(2000);
 clrscr();

As C language, does not support Hindi text directly so to display Hindi text on the output screen we need to use gotoxy () statements and display it using a “*”.

for(i=20,j=0;i>=0,j<=4;i--,j++)
 {
  gotoxy(i,j);
  cprintf("*");
 }

We will break down the text we need to display in as many portions as we can on the graph so it gets simple, so we know which loop we have to execute as many times. After breaking the text which needs to be displayed we’ll also record the coordinates which we will provide in the gotoxy () statements through which our output screen cursor will move to different positions and display the text or a line or a part of the  text.

for(i=16,j=5;i<=30,j<=8;i++,j++)
 {
  gotoxy(i,j);
  cprintf("*");
 }
for(i=16;i<=22;i++)
  {
   gotoxy(i,5);
   cprintf("*");
   }
  for(j=0;j<=8;j++)
  {
gotoxy(23,j);
   cprintf("*");
   }

after completing a single for loop the code continues to another for loop to further continue to display the rest of the text on the new location where gotoxy () statement take it to.

for(j=0;j<=6;j++)
    {gotoxy(28,j);
	  cprintf("*");
     }
    for(i=28;i<=32;i++)
    {gotoxy(i,6);

     cprintf("*");
    }for(j=0;j<=9;j++)
     {gotoxy(33,j);

      cprintf("*");
     }
     for(j=0;j<=9;j++)
     {gotoxy(37,j);
	   cprintf("*");
      }

After the Hindi text has been displayed, the function getch () holds the output screen for the user to read the text for some time and as the user presses any key it comes out of the output screen or window and the code ends.

getch();
 }

The code is easy to understand the logic, if you know in how many parts you will break the text you need to display and the coordinates where you will move the cursor so to display every part of the text correctly.

Download C Program: A Simple Use of gotoxy() to Display Hindi Text

[sociallocker]
Download C Program: A Simple Use of gotoxy() to Display Hindi Text
[/sociallocker]

Share This Article
2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

English
Exit mobile version