Write a program to print the addition of two numbers.
In this article, you will learn about the addition of two numbers by the user. I have covered all the following points. All these programs do the same things but use different approaches.
- Adding 2 integers
- Adding 2 floating type numbers
The flowchart is the same for the all given program:-
Adding two integers:-
#include<iostream>
using namespace std;
int main(){
int num1, num2, sum;
cout<<"Enter two numbers: "<<endl;
cin>>num1>>num2;
sum=num1+num2;
cout<<"\nThe result is: "<<sum<<endl;
return 0;
}
No comments:
Post a Comment