name the operator used with cout in C++
Answers
Answer:
An operator is a symbol used for performing operations on operands. An operator operates operands. The operations can be mathematical or logical. There are different types of operators in C++ for performing different operations.
Consider the following operation:
a = x + y;
In the above statement, x and y are the operands while + is an addition operator. When the C++ compiler encounters the above statement, it will add x and y and store the result in variable a.
the operator that is used with cout in c++ is << . it's is called as insertion operator,that is used to print the output .
Explanation:
<< the operation is called as insertion operation as it inserts output onto the screen.
for example, consider the a sample program
//program to print first n natural numbers
#include<iostream.h>
#include<conio.h>
void main(){
int a,i;
clrscr();
cout<<"enter how many natural numbers?";
cin>>a;
cout<<"first <<a<<natural numbers are:"<<endl;
for(i=1;i<=ai++)
cout<<i<<endl;
getch();}
here cout<<"enter how many natural numbers?";
display enter how many natural numbers? on the output screen.
here,cout is a output statement that is used in order to output a value,for this we want to use insertion operator << with this.
similarly we also extraction operator that is generally use with the cin ,the input statement used inorder to input a value or to store a value from user to a variable.
we uses >> extraction operator with cin.
Definitions
- It was Bjarne stroustrup developed c++ in AT &BELL laboratories in USA . He founded that c was lacking some simulations and decided to extend the language by adding features from OOP(Object Oriented Language),basically it was named as c with classes,later it was renamed as C++.Therefore C++ is an extension to the C by adding features of OOP.
- C has keywords like cin and cout ,the meaning and working of these keywords are known for the compiler.
- Operator are which operate upon operands,there are operators like
- Arithmetical operators
- Relatioal operators
- Logical operators
- Assignment operators
- Increment and Decrement operators
- Conditional operators.
#SPJ2