Topics
Number Systems
Program Analysis
Introduction to C+ +
- Introduction to C++
- Character Sets
- Standard I/O Strems in C++
- Type Modifiers
- C++ Data Types
- Variables in C++
- Constants
- Compiler Tokens
- Operators in C++
- Comments in C++
- Scope and Visibility
- Control Statements
- Functions in C++
- Default Arguments
- Techniques used to pass Variables into C++ Functions
- Function Overloading
- Inline Functions
- Recursion
- Pointers in C++
- Arrays in Data Structure
- References
- Type Conversion in Expressions
Visual Basic
Introduction to Networking and Internet
- Introduction to Networking Technology
- Networking Terms and Concepts
- Concept of Computer Network
- Network Security
- Network Applications
- Introduction to Standard I/O in C++
- Preprocessor directive
- Structure of C++ Program
Introduction to Standard I/O in C++
In C++, While performing Input/Output operations i.e., read data from standard input device (keyboard) and write data to standard output device (screen), Must include iostream header file in C++ program
iostream is the standard header file which contains a set of small and specific general purpose functions for handling the data
The standard input and output operations in C++ are performed by using I/O stream such as cin for input and cout for output
- cin :
The cin is used to read a number, a character, or a string of characters from a standard input device, normally the keyboard. The extraction operator (>>) is used along with cin
Syntax : cin >> variable 1 >> -- variable n
Example: cin >> a >> b; - cout :
The cout is used to display an object onto the standard device, normally the video screen. The insertion operator (<<) is used along with cout.
Syntax : cout << variable 1 << -- variable n;
Example : cout << x << y;
Preprocessor Directive
C++ provides a #define directive to define symbolic names. The #define is a directive to the C++ preprocessor. The #define directive causes a symbolic name to become defined as a macro. A macro is associated with a body. The general form of simple macro definition is
Syntax : #define macro_name body of macro
For example: #define PI 3.1459265
C++ preprocessor conceptually processes the source text of C++ program before compiler parses the source program it replaces every occurrence of a macro name in the program text with a copy of the body
Other examples of simple macros are :
#define STEP_SIZE 10
#define EOF -1
#define MAXINT 214783647
Structure of C++ Program
The C++ program contains six sections as follows :
- Include files
- Class declaration
- Class functions definitions
- Non-member function prototypes
- Main function program
- Non member function definitions
These sections may be placed in a separate code file and then compiled independently or jointly. Header files (with the .h extension) are included at the beginning using #include.
Class declarations and definitions appear before the main() function, and non-member function prototypes are declared before main() and defined after main().
Sample C++ Program
#include <iostream>
using namespace std;
int main()
{
cout << "C++ is better than C";
return 0;
}
Output : C++ is better than C
