Array function not returning correct valuse
Hi Guys, I have been trying to make a function that compares all the values of the array and if they are all equal will return a value to print true. The problem I am having is that regardless of what values I enter the function is always returning true. I couldn't really figure out a way to tell the program o check all the values in one command instead I put them each, If you guys see any thing wrong or any advice it would be greatly appreciated. Thanks again.
Code:
#include<stdio.h>
#include<stdlib.h>
int compare(int arrayA[], int arrayB[]);
int main()
{
int i = 0;
int k = 0;
int arrayA [10];
int arrayB [10];
int T = 0;
for(i = 0; i < 10; i++)
{
scanf("%d",&arrayA[i]);
}
printf("\n\n");
for(k = 0; k < 10; k++)
{
scanf("%d",&arrayB[k]);
}
T = compare(arrayA, arrayB);
if(T = 1)
{
printf("\n True");
}
else
{
printf("\n False");
}
}
int compare(intarrayA[], intarrayB[])
{
int T = 0;
if(arrayA[0] == arrayB[0] && arrayA[1] == arrayB[1] && arrayA[2] == arrayB[2] && arrayA[3] == arrayB[3] && arrayA[4] == arrayB[4] && arrayA[5] == arrayB[5] && arrayA[6] == arrayB[6] && arrayA[7] == arrayB[7] && arrayA[8] == arrayB[8] && arrayA[9] == arrayB[9])
{
T = 1;
return(T);
}
else
{
T = 0;
return(T);
}
}