#include<iostream.h>
#include<conio.h>
#include<string.h>
class X
{public:
int a[50],n;
char b[20];
char name[20];
void input()
{
 cout<<"Enter the limit upto which you want to enter ";
 cin>>n;
 cout<<"Enter the numbers ";
 for(int i=0;i<n;i++)
 {
  cin>>a[i];
 }
 cout<<"\n enter the string";
 cin>>b;
}
void large()
{
 int c;
 c=a[0];
 for(int i=1;i<n;i++)
 {
 if(c<a[i])
 c=a[i];
 }
 cout<<"Largest element is the array is "<<c;
}
void palin()
{
 int o,m,flag=0;
 o=strlen(b);
 m=o/2;
 for(int i=0;i<=m;i++)
 {
  if(b[i]!=b[o-1-i])
  { flag=1;
  }
 }
 if(flag==1)
 cout<<"\n String is not palindrome";
 else
 cout<<"\n String is palindrome";
 }
 void ninput()
 {
  cout<<"\n enter the name ";
  cin>>name;
  }
 void noutput()
 {
 cout<<"\n"<<name;
}
 };
void main()
{ int f,i,j;
  char temp[100],h;
 X *a[50];
 a[0]=new X;
 a[0]->input();
 a[0]->palin();
 a[0]->large();
 cout<<"\n Enter how many names you want to enter ";
 cin>>f;
 for(i=0;i<f;i++)
 {a[i]=new X;
 a[i]->ninput();
 }
 for(i=1;i<f;i++)
 {strcpy(temp,a[i]->name);
  h=a[i]->name[0];
  j=i-1;
  while((h<a[j]->name[0])&&(j>=0))
  {
  strcpy(a[j+1]->name,a[j]->name);
  j--;
  }
  strcpy(a[i]->name,temp);
  }
 cout<<"\n the sorted name list is as";
 for(i=0;i<f;i++)
 {
 a[i]->noutput();
 }
 getch();
 }

what is the error?

line 66: what if I enter a value of 500? Your program will blow up with that. You need to put a check in there to make sure its a value between 0 and 50.

no it gives error in line 76

Maybe you should put the check for j being greater than zero first. You might be trying to access a negative index. Have you printed out j to check what the value is?

Hello
Greetings to all members of this community.I am new member here..
nice to meet you all…….
compile time error....

@ jainny - If you are having a problem start a new thread and post what you issue is. compile time error is not enough information. You have to show your code and also what the error is.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.