Total Pageviews

Saturday, May 21, 2011

delay and gotoxy in c and c++

gotoxy and delay


gotoxy and dealy are two most useful function of c and c++........................


gotoxy use to  position cursor in specified position.................
where position is decided by value of x and y

void gotoxy(int x,int y)



Example

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

void main()
{
  clrscr();

  gotoxy(72,10);
  printf("Ashok");

  gotoxy(5,10);
  printf("Prasad");

  gotoxy(25,40);
  printf("soni");

  getch();

}

delay

dealy suspend execution  for specified time interval
 void delay(int millisecond)

Example

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


  printf("Ashok\n\t");
  delay(2200);
  printf("Prasad\n\t\t");
  delay(2200);

  printf("soni");

  getch();

}

Goto and Delay


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

  gotoxy(72,10);
  printf("Ashok\n\t");
  gotoxy(22,5);
  delay(2200);
  printf("Prasad\n\t\t");
  gotoxy(2,30);
  delay(2200);
  printf("soni");

  getch();

}

   
Example

#include<stdio.h>
#include<conio.h>
#include<dos.h>
void main()
{
  clrscr();
  textmode(BW80);
  textattr(RED);
  textbackground(CYAN);
  gotoxy(72,10);
  cprintf("Ashok");
  gotoxy(22,5);
  delay(2200);
  textattr(BLUE);
  textbackground(WHITE);
  cprintf("Prasad");
  gotoxy(12,17);
  delay(2200);
  textattr(YELLOW);
  textbackground(BLUE);
  cprintf("soni");

  getch();
}

No comments:

Post a Comment