Loading....
Coupon Accepted Successfully!

 

Using I/O Operators

  • These operators are used to get the input from the user and print the output on the screen.
  • They are classified as two types. They are
    • Input operator
      • This operator is used to get the input from the user.
      • It uses a symbol '>>' means get the input.
      • For example
        • cin >> value1;
        • The above statement shows a statement to get the input for the variable value1
    • Output operator
      • This operator is used to print the output on the screen.
      • It uses a symbol '<<' means get the output
      • For example
        • cout<<" the value of a is";
        • The above statement shows a statement to print the value of a.
Sample Program: Using I/O operator

 

// sum of two numbers

#include<iostream.h>

void main

{

int a, b, c;

cout << " enter the value of a:";

cin >> a;

cout << " enter the value of b:";

cin >> b;

c = a + b;

cout <<" the sum of a and b is:";

cout << c;

}


Output will be as shown below
Enter the value of a: 5
Enter the value of b: 3
The sum of a and b is: 8




Test Your Skills Now!
Take a Quiz now
Reviewer Name