Tuesday 31 July 2012

Lecture: 127


                                                Lecture 127

// Loop do while
#include <iostream>
#include <conio.h>
using namespace std;
 main ()
{  
   char ch;
   int count=0; 
   cout<<"Type ina phrase : \n";
   do
   {
       cout<<ch;
       count++;
   }while((ch=getch()) != '\r');   
    cout<<" \n\nCharacter count is : "<<count;
  getch();
  return 0;
}
Code view in dev compiler:

Compile the program Ctrl+F9

      Run program Ctrl+F10

Monday 30 July 2012

Lecture: 126


                                                Lecture 126
// Loop do while
//Break for loop
#include <iostream>
#include <conio.h>
using namespace std;
 main ()
{  
   int i; 
   i=1;
   do
   {
       if(i==5) break;         
    cout<<i<<" ";
    i++;
   }while(i<10);        
  getch();
  return 0;
}

Code view in dev compiler:

Compile the program Ctrl+F9

      Run program Ctrl+F10

Sunday 29 July 2012

Lecture: 125


                                                Lecture 125


// Loop do while
//Nested for loop
#include <iostream>
#include <conio.h>
using namespace std;
 main ()
{  
   int row,col; 
   row=1;
   do
   {
       col=1; 
       do
       {
            cout<<"Outer = " << row <<" Inner = "<<col<<endl;     
            col++;
       }while(col<3);//inner loop    
    cout<<endl;
    row++;
   }while(row<3);//outer loop        
  getch();
  return 0;
}
Code view in dev compiler:

Compile the program Ctrl+F9

      Run program Ctrl+F10

Saturday 28 July 2012

Lecture: 124


                                                Lecture 124

// Loop do while
#include <iostream>
#include <conio.h>
using namespace std;
 main ()
{  
  system("CLS");//Clear screen
  int F=1,i=1,j;
  cout<<"Enter the factorial number: ";
  cin>>j;
  i=1;
   do{
       F=F*i;
       i++;
     }while(i<=j);
   cout<<"Factorial of "<<j<<" = "<<F;
  getch();
  return 0;
}

Code view in dev compiler:

Compile the program Ctrl+F9

      Run program Ctrl+F10

Friday 27 July 2012

Lecture 123


                                                Lecture 123
// Loop do while
//Nested for 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;
   do
   {
       col=1;
       do
       {
          cout<<"\xdb";     
          col++;
       }while(col<70);//inner loop     
    cout<<endl;
    row++;
   }while(row<22);//outer loop        
  getch();
  return 0;
}

Code view in dev compiler:

Compile the program Ctrl+F9

      Run program Ctrl+F10

Thursday 26 July 2012

Lecture: 122


                                                Lecture 122

// Loop do while
//Nested for loop
#include <iostream>
#include <conio.h>
using namespace std;
 main ()
{  
   int row,col; 
   row=1;
   do
   {
       col=1; 
       do{
             cout<<col*row<<"\xb3";     
             col++;
         }while(col<13);//inner loop   
    cout<<endl;
    row++;
   }while(row<13);//outer loop        
  getch();
  return 0;
}

Code view in dev compiler:

Compile the program Ctrl+F9

      Run program Ctrl+F10

Wednesday 25 July 2012

Lecture: 121


                                                Lecture 121

// Loop do while
//Drawing a Graphics Character
#include <iostream>
#include <conio.h>
using namespace std;
 main ()
{  
   int n; 
   char ch[5]="\xD9";
   n=1;
   do{
        cout<<"\t"<<ch;
        n++;
     }while(n<40);
  getch();
  return 0;
}

Code view in dev compiler:

Compile the program Ctrl+F9

      Run program Ctrl+F10

Tuesday 24 July 2012

Lecture: 120


                                                Lecture 120

// Loop do while
#include <iostream>
#include <conio.h>
using namespace std;
 main ()
{  
    int n,a[5];
    cout<<"Initialisation array:\n ";
    n=0;
    do
    {
         cout<<"Enter the number: ";
         cin>>a[n];
         n++;
    }while(n<5);
    cout<<"Print the array :\n";
    n=0;
    do
    {
         cout<<a[n]<<endl;
         n++;
    }while(n<5);
    cout<<"Print the sort array :\n";
    int i,j,a1;
    i=0;
    do{
       j=i;
       do
       {
          if(a[i]>a[j])
          {
            a1=a[i];
            a[i]=a[j];
            a[j]=a1;
          }
          j++;
       }while(j<5);
       i++;
       }while(i<5); 
       n=0;
   do
    {
         cout<<a[n]<<endl;
         n++;
    }while(n<5); 
  getch();
  return 0;
}
Code view in dev compiler:

Compile the program Ctrl+F9

      Run program Ctrl+F10

Monday 23 July 2012

Lecture 119


                                                Lecture 119

// Loop do while
#include <iostream>
#include <conio.h>
using namespace std;
 main ()
{  
    int n,a[5];
    cout<<"Initialisation array:\n ";
    n=0;
    do
    {
         cout<<"Enter the number: ";
         cin>>a[n];
         n++;
    }while(n<5);
    cout<<"Print the array :\n";
    n=0;
    do
    {
         cout<<a[n]<<endl;
         n++;
    }while(n<5);
  getch();
  return 0;
}
Code view in dev compiler:
     

Compile the program Ctrl+F9

      Run program Ctrl+F10

Sunday 22 July 2012

Lecture: 118


                                                Lecture 118

// Loop do while
#include <iostream>
#include <conio.h>
using namespace std;
 main ()
{  
    int n,a[5];
    cout<<"Initialisation array:\n ";
    n=0;
    do
    {
         cout<<"Enter the number: ";
         cin>>a[n];
         n++;
    }while(n<5);
  getch();
  return 0;
}

Code view in dev compiler:

Compile the program Ctrl+F9

      Run program Ctrl+F10

Saturday 21 July 2012

Lecture: 117


                                                Lecture 117

// Loop do while
#include <iostream>
#include <conio.h>
using namespace std;
 main ()
{  
    int n,tnum,st,ed;
    cout<<"Enter the table number: ";
    cin>>tnum;
    cout<<"Enter the start table number: ";
    cin>>st;
    cout<<"Enter the end table number: ";
    cin>>ed;
    n=st;
    do
    {
      cout<<"\n"<<tnum<<" X "<<n<<" = "<<tnum*n;
      n++;
    }while(n<=ed);
  getch();
  return 0;
}

Code view in dev compiler:

Compile the program Ctrl+F9

      Run program Ctrl+F10

Friday 20 July 2012

Lecture: 116


                                                Lecture 116

// Loop do while
#include <iostream>
#include <conio.h>
using namespace std;
 main ()
{  
    int n,tnum;
    cout<<"Enter the table number: ";
    cin>>tnum;
    n=1;
    do
    {
      cout<<"\n"<<tnum<<" X "<<n<<" = "<<tnum*n;
      n++;
    }while(n<11);
  getch();
  return 0;
}

Code view in dev compiler:

Compile the program Ctrl+F9

      Run program Ctrl+F10

Tuesday 17 July 2012

Lecture: 115


                                                Lecture 115

// Loop do while
#include <iostream>
#include <conio.h>
using namespace std;
 main ()
{  
    int n;
    cout<<"Two table\n";
    n=1;
    do
    {
      cout<<"\n2  X "<<n<<" = "<<2*n;
      n++;
    }while(n<11);
  getch();
  return 0;
}

Code view in dev compiler:

Compile the program Ctrl+F9

      Run program Ctrl+F10

Monday 16 July 2012

Lecture: 114


                                                Lecture 114

// Loop do while
#include <iostream>
#include <conio.h>
using namespace std;
 main ()
{  
    int n;
    char ch;
    cout<<"An ASCII Table Program: \n";
    n=1;
    do
    {
       ch=n;
       cout<<n<<" = "<<ch<<"\t\t";
       n++;
    }while(n<256);
  getch();
  return 0;
}

Code view in dev compiler:

Compile the program Ctrl+F9

      Run program Ctrl+F10


Sunday 8 July 2012

Lecture: 113


                                                Lecture 113
// Loop do while
#include <iostream>
#include <conio.h>
using namespace std;
 main ()
{  
      int count,total;
      count=0,total=0;
      do
      {
        total=total+count;
        cout<<"Count: "<<count<<"  Total: "<<total<<endl;        
        count++;
      }while(count<10);
  getch();
  return 0;
}
Code view in dev compiler:

Compile the program Ctrl+F9

      Run program Ctrl+F10

Saturday 7 July 2012

Lecture: 112


                                                Lecture 112

// Loop do while
#include <iostream>
#include <conio.h>
using namespace std;
 main ()
{  
      int i,sum=0;
      i=1;
      do
      {
         sum+=i;             
         i++;
      }while(i<=20);
      cout<<"1 to 20 number of Sum:  "<<sum;
         
  getch();
  return 0;
}
Code view in dev compiler:

Compile the program Ctrl+F9

      Run program Ctrl+F10

Thursday 5 July 2012

Lecture: 111


                                                Lecture 111
// Loop do while
#include <iostream>
#include <conio.h>
using namespace std;
 main ()
{  
      int i;
      cout<<"Odd number: ";     
      i=1;
      do{
          cout<<i<<" ";     
          i+=2;
        }while(i<10); 
  getch();
  return 0;
}

Code view in dev compiler:

Compile the program Ctrl+F9

      Run program Ctrl+F10