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;
}

Edited 6 Years Ago by Nick Evan: Added code-tags

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

Edited 6 Years Ago by Nick Evan: Added code-tags

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;

}

Edited 6 Years Ago by Nick Evan: Added code-tags

Comments
The only useful thing in this thread is Joe's avatar; your post being 6 years late is too useless to worth a mention.
/*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();
}
This article has been dead for over six months. Start a new discussion instead.