Calculations

Cpp program to sum two numbers

Cpp program to sum two numbers

In this tutorial, we will discuss the topic of Cpp program to sum two numbers
In this topic, we will learn how to add two numbers in C++ programming language

Find Sum to numbers  Example- 1

Program 1

#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
    int f_no=45, s_no=35,sum;//variable declaration
    sum=f_no+s_no;  //find sum of integers
    cout << "sum of two numbers: "<<sum<< endl;//display result
    getch();
    return 0;
}

When the above code is compiled and executed, it produces the following results

Sum of two numbers: 80

 

Find Sum to numbers(Get input from user) – Example- 2

 

Program 2

#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
    int f_no, s_no,sum;
    cout << "Enter the first number: "<< endl;
    cin>>f_no;//get input from user for f_no
    cout << "Enter the second number: "<< endl;
    cin>>s_no;  //get input from user for s_no
    sum=f_no+s_no;  //find sum of numbers
    cout << "sum of two numbers: "<< endl;
    cout <<f_no<<" + "<<s_no<<" = "<<sum<< endl;
//display the result
    getch();
    return 0;
}

When the above code is compiled and executed, it produces the following results

Enter the first number:
75
Enter the second number:
65
sum of two numbers
75 + 65 = 140

 

In this program, the user has entered two integer values. These two values are stored in variables f_no, s_no.

Then both of values are added using plus (+) operator and stored in sum variable.

Finally, the sum is displayed on the screen

 

Similar post

C++ program to multiply two numbers using function

Java program to multiply two numbers using method

Python program to multiply two numbers using function

C# program to multiply two numbers using function

PHP program to multiply two numbers using function

 

C program to multiply two numbers 

C++ program to multiply two numbers

Java program to multiply two numbers 

Python program to multiply two numbers 

C# program to multiply two numbers 

PHP program to multiply two numbers 

JavaScript program to multiply two numbers 

 

Calculate the total of array elements in Java

Calculate the total of array elements in C

Calculate the total of array elements in C++

Java program to calculate sum of array elements

C program to calculate sum of array elements

Java Program to calculate average of array

C Program to calculate average of array

Java Program to calculate average of odd and even numbers in an array

Java Program to calculate average of odd and even numbers

C Program to calculate average of odd and even numbers in an array

C Program to calculate average of odd and even numbers

C++ Program to calculate average of odd and even numbers in an array

C++ Program to calculate average of odd and even numbers

 

Operator in Java

Data types and variable in Java

Find product of two numbers using recursion in Java

 

Operator in C++ language

Java program to sum of two numbers
Python program to sum of two numbers
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

3 weeks ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

1 month ago

Program to count vowels,consonants,words, characters and space in Java

Program to count vowels, consonants, words, characters and space in Java In this article, we…

1 month ago

How to print multiplication table using Array in C++ language

How to print multiplication table using Array in C++ language In this post, we will…

1 month ago

C Program to multiplication table using Array

C Program to multiplication table using Array In this tutorial , we will discuss about…

2 months ago

Java program to check odd or even using recursion

Java program to check odd or even using recursion In this tutorial, we discuss a…

2 months ago