errors in

hi ther, just wondering I keep getting a heap of errors on my code, can anyone point me towards were I went wrong and how to fix it? thanks in advanced

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
 #include<stdio.h>
void input(float feet , float inches);
void calc(float &feet , float &inches);
void output(float &feet , float &inches);
int main()
{
 int inches,feet,feet1, ans, inches1
{
 char ans;
 do
 {
  input(feet1,inches1);
  calc(feet1,inches1);
  printf("puteet1,inches1");
  printf("Would you like to calculate again? y/n");
  scanf(" %d",&ans );
 }
 while(ans == 'y'||ans == 'Y');
}
void input(float feet , float inches)
{
 printf("Enter feet:\n");
 scanf(" %d ",&feet);
 printf("Enter inches:\n");
 scanf(" %d",&inches);
}
void calc(float &feet , float &inches)
{
 float meters , centimeters;
 meters = feet*0.3048;
 centimeters = inches * 2.54;
}
void output(float &feet , float &inches)
{
 calc(feet,inches);
 printf("Converted feet to metres %d :\n",metres);
 printf("Converted inches to centimeters %d :\n",centimeters);
}
return 0
}
1
2
3
4
int inches,feet,feet1, ans, inches1;
...
return 0;
you went wrong in a lot of places. First, you have your functions within your main, use cout and cin, you forgot many ";", You have reference variables in the wrong place, you find meters and centimeters in one function and leave them there, you change int to float and int to char, none of which you can do. You have extra random { }. I am probably missing some.

Heres a version of your code working, most changes are not commented.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include<iostream>
#include<cctype>

using namespace std;

//changed all variables to doubles, except ans

void input(double &feet, double &inches); //<-- made them referece variables
void calc(double &feet, double &inches, double &meters, double &centimeters);
void output(double &meters, double &centimeters);

int main()
{
	double inches, feet, meters, centimeters; //<-- added ;
	char ans;

	do
	{
		input(feet,inches);
		calc(feet,inches, meters, centimeters);
		output(meters, centimeters);
		cout << "Would you like to calculate again?" << endl;
		cin >> ans;
	} while (toupper(ans) == 'Y');
	
	
	return 0; //<-- ;
}


//removed functions from main
void input(double &feet, double &inches)
{
	cout << "Enter feet:" << endl;
	cin >> feet;
	cout << "Enter inches:" << endl;
	cin >> inches;
}
void calc(double &feet, double &inches, double &meters, double &centimeters)
{
	meters = feet*0.3048;
	centimeters = inches * 2.54;
}
void output(double &meters, double &centimeters)
{
	cout << "Converted feet to metres: " << meters << endl;
	cout << "Converted inches to centimeters: " << centimeters << endl;
}
Last edited on
You should also be sure to preview your code before you post it here. Because of formatting issues, your code was difficult to read.
thanks for the help ill give the code another go and see can I get it going. thanks for the help again.
Topic archived. No new replies allowed.