2017 universities Ranking in Pakistan

Here are overall top universities of Pakistan.Some universities are at the top place in engineering fields but others are at Applied science, BA and in IT programs

Binary Search in C++

Search found at index

Quick sorting program

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Tree traversal (preorder,inorder,postorder) using linklist (c++)

Tree traversal (preorder,inorder,postorder) using linklist (c++)

Monday 11 June 2018

Sorting String in Alphabetic Order ( whole stiring sentence)


The following program sort the whole string without OOP. No object is used in this program.
Dynamic memory allocation is used.  This program can sort whole string sentence in alphabetic order.

#include<iostream>
#include<string>
using namespace std;
int main()
{
 string *p;
 int n,i;
 cout<<"Enter the size of dynamic memory allocation:"<<endl;
 cin>>n;
 int temp;
  p=new string[n];
     cout<<"Enter words:"<<endl;
     for(int i=0;i<n;i++)
    {
    cin>>p[i];
    }
   
    cout<<"You entered:"<<endl;

        for(int i=0;i<n;i++)
        {
            cout<<p[i]<<endl;   
        }

    int index[100];   

        for(int i=0;i<=n;i++)
          {
              index[i]=i;
          }

        for(int i=0;i<n;i++)
        {
            for(int j=i+1;j<n;j++)
            {
                if(p[index[i]]>p[index[j]])
                {
                temp = index[i];
                index[i] = index[j];
                index[j] = temp;
                }
            }
        }

    cout<<"The alphbetic order is:"<<endl;
    for(int i=0;i<n;i++)
    {
    cout<<p[index[i]]<<endl;
    }   
   
return 0;
}