IEO Level 2- English Olympiad (SOF) Class 9 Coaching Programs
⏳ 🎯 Online Tests (2 Tests [50 Questions Each]): NTA Pattern, Analytics & Explanations
Click Here to View & Get Complete Material
Rs. 200.00
3 Year Validity (Multiple Devices)
🎓 Study Material (303 Notes): 2024-2025 Syllabus
Click Here to View & Get Complete Material
Rs. 450.00
3 Year Validity (Multiple Devices)
🎯 250 MCQs (& PYQs) with Full Explanations (2024-2025 Exam)
Click Here to View & Get Complete Material
Rs. 200.00
3 Year Validity (Multiple Devices)
Computer Science: Introduction to C ++ : Input/Output: Stream and Description
Input/Output (I/O)
- C ++ supports input/output statements which can be used to feed new data into the computer or obtain output on an output device such as: VDU, printer etc.
- It provides both formatted and unformatted stream I/O statements.
- The following C ++ streams can be used for the input/output purpose.
- In addition to the above I/O streams, two operators are also used. The operator ≪ is known as put to or bit wise shift operator. The operator is known as extraction or get from operator.
- Let us consider a situation where the user desires to display a message “My first computer” on the screen.
- This can be achieved through the following statement: cout ≪ “My first computer;”
- Once the above statement is carried out by the computer, the message “My first computer” will appear on the screen.
- Similarly, the following program segment defines a variable sum of integer type, initializes it to value 100 and displays the contents of the variable on the screen.
- Once the above program segment is obeyed by the computer, the following output is displayed on the screen:
The value of variable sum = 100
- From the above discussion we see that cout is the standard output stream of C ++ by virtue of which output can be displayed on the screen.
- The user has defined a variable mark of integer type in the first statement and in the second statement he is trying to read a value from the keyboard. Once this set of statements is obeyed
Fig. Usage of cout and ≪
By the computer, whatever is typed on the keyboard (say 87) is received by the cin standard input stream. cin then hands over the typed value to get from operator which ultimately stores it in memory location called marks. The contents of this variable can be displayed on the screen by the statements given below:
cout ≪
We can use more than one output or put to operators within the same output statement as shown below. The activity is known as cascading of operators:
cout ≪ ≪ marks;
The output of this statement will be marks = 87