SUNIL GUTTA

SUNIL GUTTA

  • NA
  • 1k
  • 395.5k

array comparison in C language ?

Nov 11 2013 1:16 PM
Hi

my question is simple but i know to do this in other way :) but need to fallow what to be done rather not required for anyone what i done altough o/p is achieved ..

Here is my question 

Write a function with the function prototype of

int compare(double a[], double b[], int npts);

It will compare values in two arrays of the same size. If the corresponding values in each element of the

two arrays are the same, the function returns 1. Otherwise, it returns 0. Test the function with function calls

compare(a, a, 4) and compare(a, b, 4) with the arrays a = [1, 2, 3, 4], b = [1, 3, 4, 5].


I have directly wrote like this 

#include <stdio.h>

void main()
int result ;

{

int a[] = { 1, 1, 3, 4 };

int b[] = { 1, 2, 3, 3 };


int i;

for (i = 0; i < 4; i++)

{

if (a[i] != b[i])

{
printf(" 0 ");

}

else

{
printf(" 1 ");
}

}
}


So please help me to restart and re-build the program acc to requirement


Cheers thanks  


Answers (1)