Ticker

6/recent/ticker-posts

Basics of C++ | C++ Comments | Input & Output Operator in C++

Basics of C++ 

C ++ is an object oriented programming language, C ++ was developed by Jarney Stroustrup at AT & T Bell lab, USA in early eighties. C ++ was developed from c and simula 67 language. C ++ was early called ‘C with classes’. 

C++ Comments: 

C++ introduces a new comment symbol //(double slash). Comments start with a double slash symbol and terminate at the end of line. A comment may start any where in the line and what ever follows till the end of line is ignored. Note that there is no closing symbol. The double slash comment is basically a single line comment. Multi line comments can be written as follows: 

 // this is an example of 
 // c++ program 
 // thank you 
 The c comment symbols /* ….*/ are still valid and more suitable for multi line comments. 

/* this is an example of c++ program */ 

Output Operator: 

The statement cout <<”Hello, world” displayed the string with in quotes on the screen. The identifier cout can be used to display individual characters, strings and even numbers. It is a predefined object that corresponds to the standard output stream. Stream just refers to a flow of data and the standard Output stream normally flows to the screen display. The cout object, whose properties are defined in iostream.h represents that stream. The insertion operator << also called the ‘put to’ operator directs the information on its right to the object on its left. 

Return Statement: 

In C++ main ( ) returns an integer type value to the operating system. Therefore every main ( ) in C++ should end with a return (0) statement, otherwise a warning or an error might occur. 

Input Operator: 

The statement cin>> number 1; is an input statement and causes. The program to wait for the user to type in a number. The number keyed in is placed in the variable number1. The identifier cin is a predefined object in C++ that corresponds to the standard input stream. Here this stream represents the key board. 

The operator >> is known as get from operator. It extracts value from the keyboard and assigns it to the variable on its right. 

Cascading Of I/O Operator: 

cout<<”sum=”<<sum<<”\n”;

cout<<”sum=”<<sum<<”\n”<<”average=”<<average<<”\n”;

cin>>number1>>number2;

ALSO SEARCH:

"Keyword"

"input/output operator in C++"

"input operator in C++"

"ostream& operator overloading C++"

"what is insertion operator in C++"

"input and output statement in C++ "

"iostream in C++ example"