Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Leda > comparing 2 arr...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 156 of 212
Post > Topic >>

comparing 2 arrys.

by rzza@[EMAIL PROTECTED] (Lemmy) Sep 2, 2004 at 01:29 AM

this is my code and i want to compare pupilarray[] and
correctarray[].Please help me.

#include<iostream>
#include<iomanip>

using namespace std;
using std::setw;

void compare(int[], int[]);



int main(){

const int correctarraysize=5;
const int pupilarraysize=5;
int resultarraysize=5;

int pupilarray[pupilarraysize ];
int correctarray[correctarraysize]={1,2,3,4,1};
bool resultarray=0;

cout<<"\n\nEnter pupil's results:"<<endl;
for(int k=0;k<pupilarraysize;k++)
cin>>pupilarray[k];

cout<<"*************************\a**************************\a**********"<<endl;

cout<<"\nPupil's choice:"<<setw(26)<<"Answare:"
<<setw(20)<<"Results are"<<endl;

for(int j=0;j<pupilarraysize;j++)

cout<<setw(14)<<pupilarray[j]<<setw(26)<<correctarray[j]
<<setw(20)<<resultarray<<endl;
cout<<"*************************\a**************************\a***********"<<endl;
return 0;
}

void compare(int c[], int p[]){
    bool resultarray;   // <-- start out with true
    for(int i=1;i<25;i++)  {
         if( c[i] == p[i])
             resultarray = true;
         else
             resultarray = false;  // <-- if you notice I took out the
'bool' you should not declare this variable twice.
    }
    
}




 2 Posts in Topic:
comparing 2 arrys.
rzza@[EMAIL PROTECTED] (  2004-09-02 01:29:45 
Re: comparing 2 arrys.
iandemps@[EMAIL PROTECTED  2004-09-03 08:28:36 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon May 12 7:22:40 CDT 2008.