Page 72 - Modular_V2.0_C++_Flikpbook
P. 72

Program 12: To produce the following output using for loop.

                  1
                  22
                  333
                  4444
                  55555
                  #include<iostream.h>
                                                                                           DOSBox 0.74, Cpu speed: max 100%
                  #include<conio.h>
                                                                                       1
                  void main()                                                          22
                  {                                                                    333
                                                                                       4444
                      clrscr();
                                                                                       55555
                      int loop, count;
                      for(loop = 1; loop <= 5; loop++)
                      {
                          for(count = 1; count <= loop; count++)
                          {
                              cout<< loop;
                          }
                          cout<< "\n";

                      }
                      getch();
                  }
                  Program 13: To check whether the input number is a Palindrome number or not.

                  #include<iostream.h>
                  #include<conio.h>
                  void main()
                  {
                      clrscr();
                      int n, r, sum = 0, num;
                      cout<< "Enter a Number: ";
                      cin>> n;
                      num = n;
                      while(num > 0)                                 DOSBox 0.74, Cpu speed: max 100% cycles, Frames 0, Program:
                      {                                          Enter a number: 12621
                          r = num % 10;                          12621 is a Palindrome Number_

                          sum = sum * 10 + r;
                          num = num / 10;                            DOSBox 0.74, Cpu speed: max 100% cycles, Frames 0, Program:
                      }                                           Enter a number: 1234
                                                                  1234 is not a Palindrome Number_
                      if(sum == n)
                      {


                   70
                          Touchpad MODULAR (Ver. 2.0)
   67   68   69   70   71   72   73   74   75   76   77