i need help for an engineering class is this the correct syntax for this type of program to add two numbers together i need help at the line that says here this is for a c++ source file

// program
 
#iomanip
#iostream
 
include namespace std;
 
void main()
{
int number1,number2;
char answer;
 
cout<<"number1";
cin>>"number1";
 
cout>>"number2";
cin>>"number2";
 
answer=number1+number2
 
here> cout<<char<<answer<<endl;
}

I'm a newbe myself but this works:

#include <iostream>
using  namespace std;
int main()
{
int number1,number2,answer;
cout << "number1? ";
cin >> number1;
cout << "number2? ";
cin >> number2;
answer = number1 + number2;
cout << "Answer is " << answer;
}

Hope this helps
Fishman

do you use microsoft visual c++?

Hi Joe,

Fishman has given you some useful code their to get you going. Note that your own code has several basic syntax errors, which indicate that you're probably still at the "hello world" stage. Do you have a C++ book to refer to? If not, can you lay your hands on one for a little while? It'll help you enormously.

You can also find some (limited but) helpful stuff here:

http://www.robertjacobs.fsnet.co.uk/

Note that if you're using Visual C++ you'll probably have to add:

return 0;

just before the end of the main() function if you use fishman's code, otherwise you might get a compilation error.

#include<iostream>
using namespace std;
int main()

{

float i,r,e;

cout<<"Entenr Any Number:\n";
cin>>i;

cout<<"Enter Any Number:\n";
cin>>r;

e=i+r;

cout<<e<<endl;


return 0;

}
commented: The only useful thing in this thread is Joe's avatar; your post being 6 years late is too useless to worth a mention. -4

/*Program to add two numbers*/
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
cout<<"\nEnter the value for a:";
cin>>a;
cout<<"\nEnter the value for b:";
cin>>b;
cout<<"\nThe sum of a and b is:"<<a+b;
getch();
}