Code.GeekInterview.com
 
Code Samples C++
 

Using gotoxy()


Code ResourceAuthor: raghu.mohindru  

Difficulty Level: Beginner

Published: 16th Oct 2008   Read: 8718 times  

Filed in: C++
Add Comment


 

 

Sponsored Links


 

 

This program prints a big "ZORRO" on the output screen with the help of gotoxy().

 


Sample Code
  1. #include<iostream.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5.         int x,y;
  6.         clrscr();
  7.         for(x=5;x<=15;x++)         // parallel lines of z
  8.         {
  9.                 gotoxy(x,5);
  10.                 cout<<"+"<<endl;
  11.                 gotoxy(x,15);
  12.                 cout<<"+"<<endl;
  13.         }
  14.         x=5;
  15.         y=15;
  16.         while(x<=15)                // / of Z
  17.         {
  18.                 gotoxy(x,y);
  19.                 cout<<"+"<<endl;
  20.                 x++;y--;
  21.                 if(y<=5)
  22.                 break;
  23.         }
  24.         for(x=18;x<=25;x++)      // 2 sides of O
  25.         {       gotoxy(x,15);
  26.                 cout<<"+"<<endl;
  27.                 gotoxy(x,5);
  28.                 cout<<"+"<<endl;
  29.         }
  30.         for(y=5;y<=15;y++)         // 2 sides of O
  31.         {
  32.                 gotoxy(18,y);
  33.                 cout<<"+"<<endl;
  34.                 gotoxy(25,y);
  35.                 cout<<"+"<<endl;
  36.         }
  37.         for(x=28;x<=32;x++)          // Upper parallel part of R
  38.         {
  39.                 gotoxy(x,5);
  40.                 cout<<"+"<<endl;
  41.                 gotoxy(x,10);
  42.                 cout<<"+"<<endl;
  43.         }
  44.         for(y=5;y<=15;y++)            // | of R
  45.         {
  46.                 gotoxy(28,y);
  47.                 cout<<"+"<<endl;
  48.                 if(y>10)
  49.                 continue;
  50.         }
  51.         for(y=5;y<=10;y++)              // upper right part of R
  52.         {
  53.         gotoxy(32,y);
  54.         cout<<"+"<<endl;
  55.         }
  56.  
  57.         y=10;                         //Lower line of R
  58.         x=28;
  59.         while(y<=15)
  60.         {
  61.                 gotoxy(x,y);
  62.                 cout<<"+"<<endl;
  63.                 x++;
  64.                 y++;
  65.         }
  66. //        _____________________________________________________________
  67.  
  68.         for(x=35;x<=39;x++)          // Upper parallel part of R
  69.         {
  70.                 gotoxy(x,5);
  71.                 cout<<"+"<<endl;
  72.                 gotoxy(x,10);
  73.                 cout<<"+"<<endl;
  74.         }
  75.         for(y=5;y<=15;y++)            // | of R
  76.         {
  77.                 gotoxy(35,y);
  78.                 cout<<"+"<<endl;
  79.                 if(y>10)
  80.                 continue;
  81.         }
  82.         for(y=5;y<=10;y++)              // upper right part of R
  83.         {
  84.         gotoxy(39,y);
  85.         cout<<"+"<<endl;
  86.         }
  87.  
  88.         y=10;                         //Lower line of R
  89.         x=35;
  90.         while(y<=15)
  91.         {
  92.                 gotoxy(x,y);
  93.                 cout<<"+"<<endl;
  94.                 x++;
  95.                 y++;
  96.         }
  97. //      ____________________________________________________________________
  98.                 for(x=43;x<=50;x++)      // 2 sides of O   ||
  99.         {       gotoxy(x,15);
  100.                 cout<<"+";
  101.                 gotoxy(x,5);
  102.                 cout<<"+";
  103.         }
  104.         for(y=5;y<=15;y++)         // 2 sides of O
  105.         {
  106.                 gotoxy(43,y);
  107.                 cout<<"+"<<endl;
  108.                 gotoxy(50,y);
  109.                 cout<<"+"<<endl;
  110.         }
  111.         getch();
  112. }
Copyright GeekInterview.com


Next Article: Random Number Game


 

Latest Code Samples

 

Popular Code Samples

 

Related Code Samples

 

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    



Popular Coders

# Coder NameHits
1. Priya36660
2. chowsys14954
3. bipin_vaylu13577
4. raghu.mohindru8719
5. Subashini7234
6. vimal.fire6977
7. rachittyagi6626
8. venki_madesh6205
9. prabha6192
10. vipin gupta5906

Active Coders

Refined Tags