well this a parallel array and also be able to process the arrays but it doesn't do so can some one give me a hint of what i might be doing wrong. Thank you before hand.

-------------------------------------------------------------------------

#include <iostream>
#include <new>
using namespace std;

int main ()
{
  
  int DOB [10]=
{1980,1981,1982,1983,1984,1985,1986,1987,1988,1989};	
  int age [10]={60,61,62,63,64,65,66,67,68,69,70};
  string name[10]={"Luis","Sarah", "Hope", "Joseph", "Brian","Cameron","Christin","Crystal","Henry","George"};
  
  int id;
  int numbOfpeople,n;
  int * yrOfbirth;
  
  
  cout<<"Enter social ID ";
  cin>>id;
  
  cout << "Enter how many people: ";
  cin >> numbOfpeople;
  
  yrOfbirth= new(nothrow) int[numbOfpeople];
  
  if (yrOfbirth == 0)

    cout << "Error: memory could not be allocated";
  
  
  else
  {
    for (n=0; n<numbOfpeople; n++)
    {
      cout << "Enter the  year :";
      cin >> year[n];
    }
    
  }
  delete[] year;

  
  cout <<"\n\n\t\t\tHospital \n\n";
   
     cout <<"\n********************************************************************** \n" ;
    
    for (int i=0; i<12; i++)
    {
    
    if ( yrOfbirth[n]==DOB[i])
    {
     cout<<"\n\t "<<DOB[i]<< " \t\t " <<age[i]<< " \t\t "<<name[i]<<"\n"; 
     
     }
     
     }
    
     cout<<"\nThank You " ;
  
  
  
  system ("pause");
  return 0;
}

Next time use code tags.

line 36: where is year declared?

line 46: why delete year immediately after entering its values?

Do you realize you have 11 ages.
You have three fixed arrays 10 elements in size
but you are dynamically allocating number of people, entering them, then deleting the array without doing anything with it!

fixed the minor problems but is still not working.
//------------------------------------
include <iostream>

include <new>

using namespace std;

int main ()

{

int DOB [10]=

{1980,1981,1982,1983,1984,1985,1986,1987,1988,1989};

int age [10]={60,61,62,63,64,65,66,67,68,69};

string name[10]={"Luis","Sarah", "Hope", "Joseph", "Brian","Cameron","Christin","Crystal","Henry","George"};

int id;

int numbOfpeople,n;

int * yrOfbirth;

cout<<"Enter social ID ";

cin>>id;


cout << "Enter how many people: ";

cin >> numbOfpeople;


yrOfbirth= new(nothrow) int[numbOfpeople];


if (yrOfbirth == 0)

cout << "Error: memory could not be allocated";

else

{

for (n=0; n<numbOfpeople; n++)

{

cout << "Enter the year :";

cin >> year[n];

}

}

cout <<"\n\n\t\t\tHospital \n\n";

cout <<"\n********************************************************************** \n" ;

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

{

if ( yrOfbirth[n]==DOB)

{

cout<<"\n\t "<<DOB<< " \t\t " <<age<< " \t\t "<<name<<"\n";

}

}

cout<<"\nThank You " ;

system ("pause");

return 0;

commented: Where's the code tags ??? -7

Reformat, properly indent, and maybe you'll see your own problem.

Your i loop!
for (int i=0; i<12; i++)

WHAT 12 ?

Then you're using n and i for reference

What n?

WHAT 12 ?
well 12 is suppose to be of the array for DOB[12].

What n? and the n is to save the crn [n] so that it can matched the DOB [12].

WHAT 12 ?
well 12 is suppose to be of the array for DOB[12].

What n? and the n is to save the crn [n] so that it can matched the DOB [12].

well, that should give you several problems considering you declared DOB to be an array of size 10

int DOB [10]= {1980,1981,1982,1983,1984,1985,1986,1987,1988,1989};

DOB[12] would put you past the end of the array, returning who-knows-what when you try to reference it.

well for that is actually 10.
well 10 is suppose to be of the array for DOB[10].

does that makes it clearer.


What n? and the n is to save the crn [n] so that it can matched the DOB [10].

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

{

if ( yrOfbirth[n]==DOB)

{

cout<<"\n\t "<<DOB<< " \t\t " <<age<< " \t\t "<<name<<"\n";

}

commented: Has been told multiple times to use code tags in two separate threads. Refuses to do so. -4

This is amazing. You're told your problems and you still ignore us.

One last attempt and you're on your own.

I've reformatted your code like you were told to do!

int main ()
{
   int DOB [10]= {1980,1981,1982,1983,1984,1985,1986,1987,1988,1989};
   int age [10]={60,61,62,63,64,65,66,67,68,69};
   string name[10]={"Luis","Sarah", "Hope", "Joseph", "Brian","Cameron","Christin","Crystal","Henry","George"};
   int id;
   int numbOfpeople,n;
   int * yrOfbirth;

   cout<<"Enter social ID ";
   cin>>id;
   cout << "Enter how many people: ";
   cin >> numbOfpeople;
   yrOfbirth= new(nothrow) int[numbOfpeople];

   if (yrOfbirth == 0)
      cout << "Error: memory could not be allocated";
   else
   {
      for (n=0; n<numbOfpeople; n++)
      {
         cout << "Enter the year :";
         cin >> year[n];
      }
   }

   cout <<"\n\n\t\t\tHospital \n\n";
   cout <<"\n********************************************************************** \n" ;

   for (int i=0; i<12; i++)
   {
??????? WHERE IS <n> ?????????????
DOB is int DOB[10]   WHERE IS 12 ?????

      if ( yrOfbirth[n]==DOB[i])
      {
        cout<<"\n\t "<<DOB[i]<< " \t\t " <<age[i]<< " \t\t "<<name[i]<<"\n";
      }
   }

   cout<<"\nThank You " ;
   system ("pause");
   return 0; 
}

HEY thanks A lot u guys. i did what u said and it solved it. thank you so much i appreciate all your help.

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.