Corrupted Compiler

I made this program to determine the biggest value among 5 numbers using thus format. However I have error during compile. Does it because my compiler is corrupted?

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
#include <iostream>
double bigest (double a, double b, double c, double d, double e);
int main()
{
	double a, b, c, d, e;
	cout << "Value a: ";
	    cin >> a;
	cout << "Value b: ";
	    cin >> b;
	cout << "Value c: ";
	    cin >> c;
	cout << "Value d: ";
	    cin >> d;
	cout << "Value e: ";
	   cin >> e;
	cout << a; 
	cout << b;
	cout << c;
	cout << d;
        cout << e;
	cout << "Biggest value: " << big(a, b, c, d, e);
	
	return 0;
}
double big (double a,double b,double c,double d,double e);
{
	double num[5];
	for (int i = 0, i < 0; i++);
	{
		cin >> no[i];
		cout << "num: " << no[i] << endl;
	}
	
	double big;
	big = a;
	if ( b > big)
	   big = b;
	if ( c > big)
	   big = c;
  	if ( d > big)
	   big = d;
	if ( e > big)
	   big = e;
	return big;
}
	 	
	  
main.cpp: In function ‘int main()’:
main.cpp:17:2: error: ‘cout’ was not declared in this scope
cout << "Value a: ";
^
main.cpp:17:2: note: suggested alternative:
In file included from main.cpp:12:0:
/usr/include/c++/5/iostream:61:18: note: ‘std::cout’
extern ostream cout; /// Linked to standard output
^
main.cpp:18:6: error: ‘cin’ was not declared in this scope
cin >> a;
^
main.cpp:18:6: note: suggested alternative:
In file included from main.cpp:12:0:
/usr/include/c++/5/iostream:60:18: note: ‘std::cin’
extern istream cin; /// Linked to standard input
^
main.cpp:32:48: error: ‘big’ was not declared in this scope
cout << "Biggest value: " << big(a, b, c, d, e);
^
main.cpp: At global scope:
main.cpp:37:1: error: expected unqualified-id before ‘{’ token
{
^
Why would you first suspect that the compiler is corrupted, rather than your code being incorrect?

On line 2 you forward-declare bigest(), but on line 21 you call big(), and on line 25 you declare big().

Another issue, but unrelated to your problem, is that on line 34 you're declaring a variable with the same name as the function that contains it.
Last edited on
All the names in the standard library are declared in the std namespace so unless you use 'using namespace std;' or similar you need to write std:: in front of cout, cin, etc.

1
2
std::cout << "Value a: ";
std::cin >> a;


Ok i did that.. and comes out one error.

main.cpp:37:1: error: expected unqualified-id before ‘{’ token
{
^
There's a stray semicolon at the end of line 25.
repost your code. It is telling you that you either have something outside a {}
eg
int main()
int x; //no can do
{

or some other syntax error that we can't see in your old code.

double big (double a,double b,double c,double d,double e);
{
this for example is an issue.... your header (has a ;) and your body (does not) are being confused.

int foo(); //header
int foo() //body or implementation
{
return 5;
}

but this
int foo(); //is wrong
{

}
#include <iostream>
double big(double a, double b, double c, double d, double e);
int main()
{
double a, b, c, d, e;
std::cout << "Value a: ";
std::cin >> a;
std::cout << "Value b: ";
std::cin >> b;
std::cout << "Value c: ";
std::cin >> c;
std::cout << "Value d: ";
std::cin >> d;
std::cout << "Value e: ";
std::cin >> e;
std::cout << a;
std::cout << b;
std::cout << c;
std::cout << d;
std::cout << e;
std::cout << "Biggest value: " << big(a, b, c, d, e);

return 0;
}
double biggest (double a,double b,double c,double d,double e);
{
double num[5];
for (int i = 0, i < 0; i++);
{
std::cin >> num[i];
std::cout << "num: " << num[i] << endl;
}

double big;
big = a;
if ( b > big)
big = b;
if ( c > big)
big = c;
if ( d > big)
big = d;
if ( e > big)
big = e;
return big;
}
1. You still have the problem by calling your function it is big not biggest
2. also this line does not need ;
"double biggest (double a,double b,double c,double d,double e);"

3. also the for loop are alyaws like for(;;)
4. for loop does not need ;
5. endl in for loop should be std::endl.
Last edited on
Ok I am going to give you the showed-effort award and fixed it for you. I commented the changes. But you MUST learn to read the compiler errors and fix these things yourself, and you MUST learn when to use ; and when not to, or you will have trouble forever. The changes are 1-5 above in action.

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
49
50
51
#include <iostream>
double big(double a, double b, double c, double d, double e);
int main()
{

   double a, b, c, d, e;
   std::cout << "Value a: ";
   std::cin >> a;
   std::cout << "Value b: ";
   std::cin >> b;
   std::cout << "Value c: ";
   std::cin >> c;
   std::cout << "Value d: ";
   std::cin >> d;
   std::cout << "Value e: ";
   std::cin >> e;
   std::cout << a; 
   std::cout << b;
   std::cout << c;
   std::cout << d;
   std::cout << e;
   std::cout << "Biggest value: " << big(a, b, c, d, e);
   
   return 0;
}


double big (double a,double b,double c,double d,double e) //removed ; renamed function to correct name
{
   double num[5];
   for (int i = 0; i < 0; i++) //fixed comma to ; in loop, removed ; on for loop making it do nothing
   {   
      std::cin >> num[i];
      std::cout << "num: " << num[i] << std::endl; //fixed endl
   }     
   double big;
   big = a;
   if ( b > big)
   big = b;
   if ( c > big)
   big = c;
   if ( d > big)
   big = d;
   if ( e > big)
   big = e;
   return big;
}



Last edited on
Topic archived. No new replies allowed.