Hi ppl,
im back here, but now with an array problem..
this time im doin a simple program to compare the numbers in an array n then say how are they ordered.. user must type those numbers..

#include "stdafx.h"
#include <iostream>

using namespace std;

void comparison (int number[]);
void order (int number[]);
void typing (int num);

int main(int argc, char* argv[])
	int number [5], num;

	typing (num);
	order (number);
	return 0;

void comparison (int number[5])
	int i, j;

	if (number[i] > number[j])
		cout << " Elements are ordered strictly diminishing";
	else if (number[i] < number[j])
		cout << " Elements are ordered Strictly increasing";
	else if (number[i] = number[j])
		cout << " All elements are equal";
	else if (number[i] <= number[j])
		cout << " Elements are ordered diminishing";
	else if (number[i] >= number[j])
		cout << " Elements are ordered in increasing way";

thing is, compiler is givin me this error:

\vectores\vectores.cpp(52) : error C2664: 'comparison' : cannot convert parameter 1 from 'int' to 'int []'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast



9 Years
Discussion Span
Last Post by Ancient Dragon

line 25: what's the value of i and j? A: random

line 33: you are using the assignment operator = instead of the boolean operator ==.

which of the lines you posted is line 52 in your real program (error #1)


line 52:

comparison (number [5]);


void order (int number[5])
	int i;

	for (i = 0; i <=  5; i++)
		for (int j = 0; j < 5; j++)
			comparison (number [5]);

you are attempting to pass just one element of the array, not the whole array. When passing the array you have to leave out the subscripts comparison (number);

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.