hey guys, I am supposed to write 3 boolean functions listed below. my problem is that I don't really understand the questions and don't know where to start. it would be really great if someone just do one of the functions to give me an example so i could finish the rest.


WRITE A FUNCTION NAMED EQUALBUTOPPOSITE. THE FUNCTION SHOULD ACCEPT TWO INTEGER ARRAYS AND A SIZE ARGUMENT. IT SHOULD RETURN TRUE IF THE ARRAYS HAVE THE SAME VALUES, BUT IN THE OPPOSITE ORDER.

WRITE A FUNCTION NAMED AVERAGEOFNEIGHBORS. THE FUNCTION SHOULD ACCEPT AN ARRAY OF FLOATS, AND A SIZE ARGUMENT. IT SHOULD RETURN TRUE IF EACH ELEMENT IS THE AVERAGE OF IT'S NEIGHBORS ON EITHER SIDE (WITH THE EXCEPTION OF THE FIRST AND LAST ELEMENTS, THEY CAN HAVE ANY VALUE) OTHERWISE IT SHOULD RETURN FALSE.

WRITE A FUNCTION NAMED ALLVALUESAREPAIRED. THIS FUNCTION SHOULD ACCEPT AN ARRAY OF CHARS, AND A SIZE ARGUMENT. IT SHOULD RETURN TRUE IF EACH VALUE IN THE ARRAY IS INCLUDED EXACTLY TWICE. NO VALUES APPEAR JUST ONCE IN THE ARRAY, AND NO VALUES APPEAR MORE THAN TWICE.

below is my code.. i know it's totally wrong..please help!

bool equalbutOpposite(int array[],int size)
{
	bool status;
	
	
	

	if(  == y)
	status = true;
	else
	status = false;
	
	return status;
}

my problem is that I don't really understand the questions and don't know where to start.

You deserve a piece of cake

so far i have gotten the code for 1 and 2. thanks for the link! I am not really sure if i am writing the right code for 2. please correct me if i am wrong.thanks. also, any idea on how to compare each value is included in an array twice?

bool equalbutOpposite(int array1[],int array2[], int size)
{
    for (int i = 0; i < size; i++)   
    {
        if(  array1[i] != array2[size-1-i] )
            return false;
    }
   
    return true;
}


bool averageofneighbors(float array[], int size)
{   
    float total = 0
    float average;
    for(int count = 0; count < size; count++)
    total +=array[count];
   
    average = total/size;
   

    for(int i = 0; i < size; i++)
    {
        if(array[i] != array[size-1])
            return false;
       
    }
    return true;
}



bool allvaluesarepaired(char array[], int size)
{   
    for(int i = 0; i < sizse, i++)
    {
        if(

so far i have gotten the code for 1 and 2.

Congrats!

please correct me if i am wrong.thanks.

Just make simple sample to test your software if is working correctly :)

any idea on how to compare each value is included in an array twice?

Can you clarify this please

"THIS FUNCTION SHOULD ACCEPT AN ARRAY OF CHARS, AND A SIZE ARGUMENT. IT SHOULD RETURN TRUE IF EACH VALUE IN THE ARRAY IS INCLUDED EXACTLY TWICE. NO VALUES APPEAR JUST ONCE IN THE ARRAY, AND NO VALUES APPEAR MORE THAN TWICE." I am not really sure how i am supposed to compare values that appear exactly twice.

use double (Nested?) for loop
1st loop will iterate though the array and for each array element, It will iterate though same array, but now comparing stuffs. To get flavor of what i'm saying compile the program below and change it to suit your need. The key concept is there

#include <iostream>

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

int main(){
	int xyz[3]={1,2,3};
	compare(xyz, 3);
}

void compare(int Xarray[3],  const int size){
	int i;
	int j;
	for(i=0; i<size; i++){
		for(j=0;j<size;j++){
			//compare Xarray[i] and Xarray[j] here and do your other if..else
			std::cout<<Xarray[i]<<" Compared to "<<Xarray[j]<<std::endl;
		}
	}
}

thank you so much! I now have an idea of what to do.

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.