Thursday 21 June 2012

Lecture: 98


                                                Lecture 98
//Nested while loop
//fills square area on screen
#include <iostream>
#include <conio.h>
#include <windows.h>
HANDLE wHnd;
using namespace std;
 main ()
{  
  system("CLS");//Clear screen
  int row,col; 
  row=1;
   while(row<22)//outer loop
   {
       col=1;
       while(col<40)//inner loop
       {
          COORD c;
          c.X=row; c.Y=col;
          SetConsoleCursorPosition(wHnd,c);
          cout<<"\xdb";     
          col++;
       }     
    cout<<endl;
    row++;
   }         
  getch();
  return 0;
}

Code view in dev compiler:

Compile the program Ctrl+F9

      Run program Ctrl+F10