FUNCTION

/*To find how many smilar numbers in array and which is it and
To find sum of numbers in array by using functions*/

#include<iostream>
int findsmilarnumbers ( int number[], int count )
{
int result = 0;
for ( int i=0; i<count; i++ )
{
for ( int j=0; j<count; j++ )
{
if (numbers[i] == numbers[i]&& ( i != j ))
{
result ++;
}
}
return result;
}
int sum ( int numbers[], int count )
{
int result = 0;
for ( int i=0; i<count; i++ )
{
result = numbers[i];
}
return result;
}
void man()
}

int main ()
{
int a[4] = {1,2,2,3};
int count = 4;
int smilarnumber = findsmilarnumbers( a, count );
int sum = sum( a, count );
cout <<" smilar numbers count "<< smilarnumber;
cout <<" sum of numbers "<< sum;
return 0;
}
i think you meant

 
if (numbers[i] == numbers[j] && ( i != j ))


1
2
3
4
5
6
7
8
9
10
11
for ( int i=0; i<count; i++ )
{
for ( int j=0; j<count; j++ )
{
if ((numbers[i] == numbers[j]) && ( i != j ))
{
result ++;
}
}
return result;
}
Topic archived. No new replies allowed.