Professional Documents
Culture Documents
1/29/18
Addition of Integers
// Example program
#include <iostream>
using namespace std;
int main()
{
int x;
int y;
cin>>x;
cin>>y;
cout<<x+y<<endl;
}
// Example program
#include <iostream>
using namespace std;
int main()
{
int x;
int y;
cin>>x>>y;
cout<<"The sum of x and y is "<<x+y<<endl;
}
Wrong Code:
// Example program
#include <iostream>
using namespace std;
int main()
{
int x;
int y;
int z=x+y;
cin>>x>>y;
cout<<"The sum of x and y is "<<z<<endl;
}
Right Code:
// Example program
#include <iostream>
using namespace std;
int main()
{
int x;
int y;
cin>>x>>y;
int z=x+y;
cout<<"The sum of x and y is "<<z<<endl;
}
Large Number:
// Example program
#include <iostream>
using namespace std;
int main()
{
int y=15;
int x=21474864800000000;
int z=x+y;
cout<<z;
}