Code.GeekInterview.com
  I am new, Sign me up!
 
Code Samples C++
 

Using gotoxy()


Code ResourceAuthor: raghu.mohindru  

Difficulty Level: Beginner

Published: 16th Oct 2008   Read: 4429 times  

Filed in: C++
Add Comment


 


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 Comment


Members Please Login

Name:  Email: (Optional. Used for Notification)

Title:
 
Comment:
Validation Code: <=>  (Enter this code in text box)





Popular Coders

# Coder NameHits
1. Priya11453
2. bipin_vaylu5084
3. chowsys5009
4. raghu.mohindru4430
5. venki_madesh3286
6. vimal.fire2999
7. Subashini2644
8. prabha2484
9. vipin gupta2073
10. Mehedi Shams Rony1830

Active Coders

Refined Tags

 

Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact  

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape