ISC Solved Important Question Computer Science

ISC Board Solved Important Question

Subject - Computer Science

Question.

A class Sort Word has been defined with the following details:

Class Name                                          : Sort Word

Data Members/instance variables:

             Txt                                        : stores the word

             Len                                       : stores the length of the word

             Member Functions:

             SortWord ()                          : default constructor

             Void readTxt                        : to accept the word in lower case

              Void sortTxt  ()                  : to sort the word in alphabetical order of characters using bubblesort technique and display it

              Void changeTxt ()             : to change the case of vowels in the word to UPPER case (for e.g. school become schOOL)

             Void disp()                         : to display the changed string

Specify the class SortWord giving the details of the functions constructor, void readTxt(), void sortTxt(), void changeTxt() and void disp(). You need not write the main function.

Answer:

Class Sortward

     { private

       char str[10];

       int 1;

   public;

      Sortword();

      void readTxt()

        { cin.getline (str, 10);

         }

       void sortTxt();

       void changeTxt();

        }; void disp();

            void Sortword :: SortTxt()

       {

          char t[1];

          for (int i=0; i<10;i++)

         {

           for(int j=0; j<10-1-i; j++)

               {if(str[j]>str[j+1])

                 { t[0] = str[j+1];

                 str[j+1]=t[0];

                 }

              }

         }

    }

     void sort.word :: changeTxt()

   { int len = strlen(str);

      for(int i=0; i<1; i++)

        { if(str[i] =='a'|| str[i]=='e' || str[i]=='i' || str[i]=='o' || str[i]=='u')

          {str[i]=toupper(str[i]);

           }

        }

     }

       void Sort Word :: disp ()

    { cout.write(str,10);

     }

    sortWord:: sortWord

    { for(int i=0; i<10; i++)

      str[] = ‘’;

       }