Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Whats wrong with this beginner code? 1

Status
Not open for further replies.

LPlates

Programmer
Jun 5, 2003
554
AU
#include <iostream.h>

void multiply(int &number, int &numberTwo); //Prototype

int main()
{
int a,b;
long int answer;
cout<<&quot;Enter two numbers separated by spaces: &quot;;
cin>>a>>b;
answer=multiply(a,b); //&quot;answer&quot; gets the return from the second variable as its value
cout<<&quot;\nThe product of those two numbers is &quot;<<answer<<&quot;.&quot;;
}
void multiply(int &number, int &numbertwo) //Dummy variables
{
return number*numbertwo; //Returns the answer to &quot;answer&quot; variable in main() because we assigned this value to that variable
}
 
you have two errors
1. function should be int instead of void
2. function main should erturn a value. For example put a
return 0; in the bottom of function.
The next ones could eb an error in dependention of version of VisualStudio:
3. If you want this code to be compatible with VisualStudio .NET 2003 you should
#include<iostream> instead of #include<iostream.h>
and use std::cin instead of cin.

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
and std::cout instead of cout

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top