Hey, I am just learning functions. I was wondering if you could tell me why this piece of code is not implementing the 'values' function.

#include <iostream>
#include <windows.h>
#include <string>
#include <iomanip>
void values(float value1[11]);
using namespace std;
float value1[11], value2[11];
int main()
{
	cout << setiosflags(ios::fixed) << setprecision(2) << ios::showpoint;

	float value1[11], value2[11];
	char gauge[1], info;

	cout << "Welcome to my program, which converts celsius into fahrenheit,\nor fahrenheit into celsius.\n\n";
	do{
	cout << "**********\nCelsius - c\n**********\n\n";
	cout << "**********\nfahrenheit - f\n**********\n\n";
	cout << "Please enter the gauge that you would like to convert: ";
	cin >> info;
	if((info!='c')&&(info!='f'))
	{
		system("cls");
		cout << "You must enter 'c' or 'f'";
		system("pause");
		system("cls");
	}
	}while((info!='c')&&(info!='f'));
	system("cls");
	cout << "Please enter the temperature that you would like to see converted: ";
	cin >> value1[5]; 
	if(info == 'c')
	{
		gauge[0]='C';
		gauge[1]='F';
		values;
		for(int x=0;x<=10;x++)
			value2[x]=(value1[x]*9)/5+32;
	}
	else
	{
		gauge[0] = 'F';
		gauge[1] = 'C';
		values;
		for(int x=0;x<=10;x++)
			value2[x] = ((value1[x] - 32) * 5)/9;
	}
	system("cls");
	cout << setw(32) << gauge[0] << " |          | " << gauge[1] << endl; 
	cout << setw(45) << "|          |" << endl;
	for(int x=0;x<=4;x++)
		cout << setw(32) << value1[0+x] << "-|          |-" << value2[0+x] << endl;
	for(int x=0;x<=5;x++)
		cout << setw(32) << value1[5+x] << "-|**********|-" << value2[5+x] << endl; 
	cout << setw(45) << "|**********|" << endl; 
	cout << setw(46) << "/************\\" << endl; 
	cout << setw(47) << "/**************\\" << endl; 
	for(int x = 1; x<=5;x++)
		cout << setw(48) << "|****************|" << endl; 
	cout << setw(47) << "\\**************/" << endl; 
	cout << setw(46) << "\\************/" << endl; 

	return 0;
}
void values(float value1[11])
{
	for(int x=5;x>=1;x--)
		value1[x-1] = value1[x] + 1;
	for(int x=5;x<=9;x++)
		value1[x+1] = value1[x] - 1;
}

If lines 36 and 44 are supposed to be function calls, you need to put () after the function name. Please correct me if I am wrong, but I think thats the problem.

EDIT
You will need to put in a parameter as well. MAke sure it is the same data type as the one in the function definition.
Sorry I missed that at first glance/

Oh, ok. Ty. Sadly I have no clue what a parameter is..I shall look it up though. Thanks again for the information.

Oh, ok. Ty. Sadly I have no clue what a parameter is..I shall look it up though. Thanks again for the information.

A parameter is what goes in the parentheses after a function call. The function call and the function definition must contain the same amount of parameters and they must be of corresponding data types. That explanation may be a little unclear. Look it uo online for more info.

A parameter is what goes in the parentheses after a function call. The function call and the function definition must contain the same amount of parameters and they must be of corresponding data types. That explanation may be a little unclear. Look it uo online for more info.

Ah, ok. I tried this...but it still doesn't work:

......
	if(info == 'c')
	{
		gauge[0]='C';
		gauge[1]='F';
		values(float value1[11]);
		for(int x=0;x<=10;x++)
			value2[x]=(value1[x]*9)/5+32;
	}
	else
	{
		gauge[0] = 'F';
		gauge[1] = 'C';
		values(float value1[11]);
		for(int x=0;x<=10;x++)
			value2[x] = ((value1[x] - 32) * 5)/9;
	}
...............

Are you getting compile errors or is it just not doing what you want it to do? If you are getting compiler errors, post them here.

Ok.

1>.\ultima.cpp(36) : error C2144: syntax error : 'float' should be preceded by ')'
1>.\ultima.cpp(36) : error C2660: 'values' : function does not take 0 arguments
1>.\ultima.cpp(36) : error C2059: syntax error : ')'
1>.\ultima.cpp(44) : error C2144: syntax error : 'float' should be preceded by ')'
1>.\ultima.cpp(44) : error C2660: 'values' : function does not take 0 arguments
1>.\ultima.cpp(44) : error C2059: syntax error : ')'

Oh , remove the word float from the function calls.
I shoulda spotted that earlier.

Ah, ok. I tried this...but it still doesn't work:

......
	if(info == 'c')
	{
		gauge[0]='C';
		gauge[1]='F';
		values(float value1[11]);
		for(int x=0;x<=10;x++)
			value2[x]=(value1[x]*9)/5+32;
	}
	else
	{
		gauge[0] = 'F';
		gauge[1] = 'C';
		values(float value1[11]);
		for(int x=0;x<=10;x++)
			value2[x] = ((value1[x] - 32) * 5)/9;
	}
...............

your function call should be :

values(value1);

your function call should be :

values(value1);

:) Thanks so much.

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.