
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C++ Program to Take Integer and Float as Input and Return Their Sum
Suppose we have two numbers a and b, a is integer and b is a float. We shall have to take them from standard input and display the sum.
So, if the input is like a = 10 b = 56.23, then the output will be Sum: 66.23
To solve this, we will follow these steps −
To display output into the standard output device we can use extraction operator (<<)
To take input from standard input we can use insertion operator (>>)
Example
Let us see the following implementation to get better understanding −
#include <iostream> using namespace std; int main(){ int a; float b; cout << "Enter numbers:" << endl; cin >> a >> b; cout << "Sum:" << a + b; }
Input
10, 56.23
Output
Enter numbers: Sum:10
Advertisements