Module-1.C
Module-1.C
"
Introduction
Origins (1972): C++ evolved from the C programming language, created by Dennis
Ritchie for system programming.
Birth of "C with Classes" (1979–1983): Bjarne Stroustrup developed "C with Classes" to
add object-oriented programming (OOP) features to C, including classes, inheritance,
and type-checking.
Renamed to C++ (1983): The name "C++" symbolized an incremental improvement over
C.
First Release (1985): The first official version introduced OOP features, function
overloading, and basic I/O.
Key Milestones: C++ 2.0 (1989): Added multiple inheritance, abstract classes, and
templates.
Modernization:
C++ directives are commands used to include specific functionalities in a program. The
most common directive is #include, which allows the program to include header files
necessary for input, output, and other operations. For example:
#include <iostream>
This directive includes the iostream header file, which is essential for input and output
operations.
Header Files
Header files in C++ contain declarations of functions, classes, and constants that can
be reused across multiple programs. Some commonly used header files include:
Using header files helps modularize the program and avoid rewriting code.
Variables
Variables are placeholders used to store data in a program. They are given a name
and a data type. For example:
Data Types
C++ supports various data types to define variables. Common data types include:
The syntax and format of C++ refer to the rules and structure that a program must
follow. Key components of C++ syntax include:
#include <iostream>
using namespace std;
int main() {
cout << "Hello, World!";
return 0;
}
Output Statement
Output statements in C++ display information to the user. The cout object, along with
the insertion operator (<<), is used for output:
#include <iostream>
using namespace std;
int main() {
cout << "This is an output statement." << endl;
return 0;
}
Input Statement
Input statements allow users to provide data to the program. The cin object, along with
the extraction operator (>>), is used for input:
#include <iostream>
using namespace std;
int main() {
int age;
cout << "Enter your age: ";
cin >> age;
cout << "You entered: " << age << endl;
return 0;
}