# C++ Exercises

## C++ Program to calculate the sum of two numbers.

Let see the program add two numbers.

```Example:
Declare three variables they are integer or float data types x, y,z.
Declare one int data type and one float datatype, then store float data type.
Declare two float data type, then store float data type.
Declare two integer data types, then store integer data type.
Input x=10,y=20
Then z=x+y
Sum two numbers z=30.
```

```#include <iostream>

using namespace std;
int main()
{
int x;
float y,z;
cout<<"Enter x value :";
cin>>x;
cout<<"Enter y value :";
cin>>y;
z=x+y;
cout<<" Sum of two numbers :"<<z<<endl;
return 0;
}

```

##### Output:

```Enter x value :31
Enter y value :31.36
Sum of two numbers :62.36

```

```#include <iostream>

using namespace std;
int main()
{
float x,y,z;
cout<<"Enter x value :";
cin>>x;
cout<<"Enter y value :";
cin>>y;
z=x+y;
cout<<" Sum of two numbers :"<<z<<endl;
return 0;

}

```

##### Output:

```Enter x value :31.10
Enter y value :36.10
Sum of two numbers :67.2

```

```#include <iostream>

using namespace std;
int main()
{
int x,y,z;
cout<<"Enter x value :";
cin>>x;
cout<<"Enter y value :";
cin>>y;
z=x+y;
cout<<" Sum of two numbers :"<<z<<endl;
return 0;
}

```

##### Output:

```Enter x value :31
Enter y value :36
Sum of two numbers :67

```