Borland C++ programming quistion, what's wrong with my program

tj00343
Messages
59
Reaction score
0
This program is supposed to add 2 integers ,according to the compiler, there are 2 warnings and 1 error ,the error is (undefined symbol' end')
the warnings are 'sum' and 'y' are declared but never used

here is the program :

# include <iostream>
# include <conio.h>
intmain()
{
int x;
int y;
int sum;
count<< "enter 2 integers " ;
cin>>x ;//read an integer and store it in sum x+y ; x
count<<"the sum of" <<x<< "and" <<y<< "is" <<sum<< end;
getch();
return 0;
}

What's wrong with it. thanks in advance to anyone who answers
Btw. the compiler I'm using is Borland C++ 5.0
 
on Phys.org
Warnings are a little bit off IMHO, but error is obvious.

'end' is not defined (hint: check documentation what is the correct name you should be using, you want to end line).

y & sum are declared and used - but at he moment of their use programs has no chances of knowing what their values are.
 
tj00343 said:
This program is supposed to add 2 integers ,according to the compiler, there are 2 warnings and 1 error ,the error is (undefined symbol' end')
the warnings are 'sum' and 'y' are declared but never used

here is the program :
Code:
# include <iostream>
# include <conio.h>
intmain()
{
   int x;
   int y;
   int sum;
	cout<< "enter 2 integers " ;
   cin>>x ;//read an integer and store it in sum x+y ; x
   cout<<"the sum of" <<x<< "and" <<y<< "is" <<sum<< end;
   getch();
   return 0;
   }
What's wrong with it. thanks in advance to anyone who answers
Btw. the compiler I'm using is Borland C++ 5.0

line 3: "intmain" function
line 9: You have commented out what you evidently mean to be executable code.
line 9: Your comment exhibits faulty thinking. You can't read in a value and store it in an expression. You can only store a value in a variable. x + y is not a variable.
line 10: As the warning indicates, your program is attempting to use variables--y and sum-- that haven't been properly initialized. What will be displayed will be "garbage" values.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 75 ·
3
Replies
75
Views
7K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 17 ·
Replies
17
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K