so this is what I have done

#include<iostream>

#include<string>
void menu();

using namespace std;
char choice;

void digcom ();

void matrices ();

int main ()

{ menu();



return 0;

}
void menu()
{
cout<<"\tMENU" <<endl<<"MATHEMATICS(matrices select A)\n"<<"DIGITAL COMMS select B\n"<<"c TO EXIT"<<endl;

cin>>choice;

while(choice!='c')
{

switch(choice)

{

case ('A') : matrices();break;

case ('B'): digcom();break;

default:cout<<"re-enter\n";
cin>>choice;break;

}
}
}// end of menu

void digcom()

{

 string ans;

 int *score;

 score=new int;  // dynamic memory allocation

 if(score==NULL)

 {

 cerr<<"insufitient space could not allocate memory"<<endl;

 exit(1);

 }

string questions[10]={"State the basic form of representation of a image","What does LAN stand for","What type of data transmission allows data to only flow in one direction","in a wireless network data is transmitted at the speed of __","which is___","determine the propagation delay associated with a connectionless communication channel through a private telephone network","What does modem stand for","what does IP stand for","what format is used to store data"};

string answers[10]={"pixels","Local Area Network","simplex","light,5*10^-8","5*10^-6","modulator-demodulator","Internet Protocol","digital format"};

string store[10];

cout<<"MAKE SURE THAT UR ANSWERS ARE IN SMALL LETTER UNLESS STATING THE ABBREVIATION"<<endl;

*score=0;

for(int n=0;n<9;n++)

{

cout<<questions[n]<<endl;

getline(cin,ans);

int f=ans.length();

store[n]=ans.substr(0,f);   // string function

}

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

{

if(answers[i]==store[i])

{

*score++;  // pointer is incremented   possible use before definition

}

}

cout<<"you got "<<*score<<"/10"<<endl;

delete score;


menu();

} // end of this function



void matrices() // new function
{

int q1[4],q2[4],q3[4];
float da,dx,dy,dz,x,y,z,*ptr2;;
cout<<"\nTHE EQUATION MUST BE ENTERED USING CO-OEFICIENTS ONLY"<<endl
    <<"ENTER EQUATION 1"<<endl;
  for(int a=0;a<=3;a++)
    {
      cin>>q1[a];
    }

cout<<"\nEQUATION 1 COMPLETE, ENTER EQUATION 2"<<endl;

 for(int b=0;b<=3;b++)
   {
    cin>>q2[b];
   }

cout<<"\nEQUATION 2 COMPLETE, ENETR EQUATION3"<<endl;
 for(int c=0;c<=3;c++)
   {
    cin>>q3[c];
   }
int d,e,f,*pointer1;
// DET A
   pointer1=q1;
   d=*pointer1*((q2[1]*q3[2])-(q3[1]*q2[2]));
   pointer1++;
   e=*pointer1*((q2[0]*q3[2])-(q3[0]*q2[2]));
   pointer1++;
   f=*pointer1*((q2[0]*q3[1])-(q3[0]*q2[1]));
   pointer1++;
   da=d-e+f;

//DET X
   d=*pointer1*((q2[1]*q3[2])-(q3[1]*q2[2]));
   pointer1-=2;
   e=*pointer1*((q2[3]*q3[2])-(q3[3]*q2[2]));
   pointer1++;
   f=*pointer1*((q2[3]*q3[1])-(q3[3]*q2[1]));
   dx=d-e+f;

//DET Y
   pointer1=q1;
   d=*pointer1*((q2[3]*q3[2])-(q3[3]*q2[2]));
   pointer1+=3;
   e=*pointer1*((q2[0]*q3[2])-(q3[0]*q2[2]));
   pointer1--;
   f=*pointer1*((q2[0]*q3[3])-(q3[0]*q2[3]));
   dy=d-e+f;

//DET Z
   pointer1=q1;
   d=*pointer1*((q2[1]*q3[3])-(q3[1]*q2[3]));
   pointer1++;
   e=*pointer1*((q2[0]*q3[3])-(q3[0]*q2[3]));
   pointer1+=2;
   f=*pointer1*((q2[0]*q3[1])-(q3[0]*q2[1]));
   dz=d-e+f;


float t[3];
t[0]=dx/da;
t[1]=dy/da;
t[2]=dz/da;


cout<<"\n...........OPTIONS........."<<endl
    <<"1. CALCULATE THE VALUE OF X"<<endl
    <<"2. CALCULATE THE VALUE OF Y"<<endl
    <<"3. CALCULATE THE VALUE OF Z"<<endl
    <<"4. CALCULATE ALL THE VALUES"<<endl
    <<endl<<"ENTER YOUR CHOICE"<<endl;
cin>>d;

if(d==4)
 {
  ptr2=t;
  cout<<"THE VALUE OF X IS: "<<*ptr2<<endl;
  ptr2++;
  cout<<"THE VALUE OF Y IS: "<<*ptr2<<endl;
  ptr2++;
  cout<<"THE VALUE OF Z IS: "<<*ptr2<<endl;
 }

  else
   {
    cout<<"THE VALUE IS: "<<t[d-1]<<endl;
   }
menu();
}

theproblem is with the digcom after it has run it tells me of a error abou the pointer

Recommended Answers

All 2 Replies

Member Avatar for iamthwee

What are you inputting for digcom?

Show us an exact example

void digcom()
{
  string ans;
  int *score;
  score = new int; // dynamic memory allocation

  if ( score == NULL )
  {
    cerr << "insufitient space could not allocate memory" << endl;
    exit ( 1 );
  }

  string questions[10] = {"State the basic form of representation of a image", "What does LAN stand for", "What type of data transmission allows data to only flow in one direction", "in a wireless network data is transmitted at the speed of __", "which is___", "determine the propagation delay associated with a connectionless communication channel through a private telephone network", "What does modem stand for", "what does IP stand for", "what format is used to store data"};
  string answers[10] = {"pixels", "Local Area Network", "simplex", "light,5*10^-8", "5*10^-6", "modulator-demodulator", "Internet Protocol", "digital format"};

  string store[10];

  cout << "MAKE SURE THAT UR ANSWERS ARE IN SMALL LETTER UNLESS STATING THE ABBREVIATION" << endl;

  *score = 0;

  for ( int n = 0; n < 9; n++ )
  {
    cout << questions[n] << endl;
    getline ( cin, ans );
    int f = ans.length();
    store[n] = ans.substr ( 0, f ); // string function
  }

  for ( int i = 0; i < 10; i++ )
  {
    if ( answers[i] == store[i] )
    {
      *score++; // pointer is incremented possible use before definition
    }
  }

  cout << "you got " << *score << "/10" << endl;

  delete score;
  menu();

} // end of this function

Plus you don't need a pointer to simply increment a score count. Hell you don't even need an array. The part in red doesn't make sense either.

Please take the time you need to get familiar with code tags

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.