Search PPTs

Thursday, July 25, 2013

PPT On C++ Basic Input/Output

Presentation On C++ Basic Input/Output
Download

C++ Basic Input/Output Presentation Transcript:
1.C++ Basic Input/Output

2.C++ Basic Input/Output
The C++ standard libraries provide an extensive set of input/output capabilities which we will see in subsequent chapters. This chapter will discuss very basic and most common I/O operations required for C++ programming.
C++ I/O occurs in streams, which are sequences of bytes. If bytes flow from a device like a keyboard, a disk drive, or a network connection etc. to main memory

3.this is called input operation and if bytes flow from main memory to a device like a display screen, a printer, a disk drive, or a network connection, etc, this is called output operation.

4.I/O Library Header Files:

5.The standard output stream (cout):
The predefined object cout is an instance of ostream class. The cout object is said to be "connected to" the standard output device, which usually is the display screen. The cout is used in conjunction with the stream insertion operator, which is written as << which are two less than signs as shown in the following example.

6.#include
using namespace std;
int main( )
{
char str[] = "Hello C++";
cout << "Value of str is : "
<< str << endl;
 }
When the above code is compiled and executed, it produces following result:
Value of str is : Hello C++
 

7.The C++ compiler also determines the data type of variable to be output and selects the appropriate stream insertion operator to display the value. The << operator is overloaded to output data items of built-in types integer, float, double, strings and pointer values.
The insertion operator << may be used more than once in a single statement as shown above andendl is used to add a new-line at the end of the line.

8.The standard input stream (cin):
The predefined object cin is an instance of istream class. The cin object is said to be attached to the standard input device, which usually is the keyboard.
The cin is used in conjunction with the stream extraction operator, which is written as >> which are two greater than signs as shown in the following example.

9.#include
using namespace std;
int main( )
{
char name[50];
cout << "Please enter your name: ";
 cin >> name;
 cout << "Your name is: " << name << endl;
}
 

10.You enter a value and then hit the enter to see the result something as follows:
Please enter your name:
cplusplus Your name is: cplusplus
The C++ compiler also determines the data type of the entered value and selects the appropriate stream extraction operator to extract the value and store it in the given variables.
The stream extraction operator >> may be used more than once in a single statement. To request more than one datum you can use the following:

No comments:

Related Posts Plugin for WordPress, Blogger...

Blog Archive