C++ Programming Blog

 
 
 

Image

 #include<iostream.h>
 #include<conio.h>



 //-----------------------------  Main( )  -------------------------------//



 main()
    {
       clrscr();

       cout<<\"\\n ******** Even numbers b/w 0 to 50 ********* :\"<<endl;


       cout<<\"\\n\\n Using while loop : \"<<endl;
       int count_1=0;

       while(count_1<=50)
      {
         if(count_1%2==0)
         cout<<\"  \"<<count_1;
         count_1++;
      }

       cout<<\"\\n\\n Using do-while loop :\"<<endl;

       int count_2=0;

       do
      {
         if(count_2%2==0)
         cout<<\"  \"<<count_2;
         count_2++;
      }
       while(count_2<=50);

       cout<<\"\\n\\n Using for loop :\"<<endl;

       for(int count_3=0;count_3<=50;count_3++)
      {
         if(count_3%2==0)
         cout<<\"  \"<<count_3;
      }

       getch();
       return 0;
    }