C++ Program to Add Two Numbers | C++ Practice Program

Publié le: 28 mars 2023
sur la chaîne: CodeDWork
394
4

C++ Program to Add Two Numbers
This is a C++ program that prompts the user to enter two integers, reads them in using the cin input operator, adds them together, and then prints out the sum using the cout output operator.

The program starts by declaring three integer variables - first_number, second_number, and sum - using the int keyword.

The cout statement then prompts the user to enter two integers, and the cin statement reads in these values and assigns them to first_number and second_number.

The next line calculates the sum of the two numbers and stores it in the variable sum.

Finally, the program prints out the sum in a human-readable format using the cout statement. The output shows the two numbers entered by the user, followed by the calculated sum.

For example, if the user enters the values 4 and 5, the output of the program would be:

Enter two integers: 4 5
4 + 5 = 9
The program then returns 0, indicating that it has executed successfully.


Sur cette page du site, vous pouvez voir la vidéo en ligne C++ Program to Add Two Numbers | C++ Practice Program durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur CodeDWork 28 mars 2023, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 394 fois et il a aimé 4 téléspectateurs. Bon visionnage!