0% found this document useful (0 votes)
14 views

Module-1.C

This document provides an introduction to programming with a focus on C++, detailing its history, key milestones, and modern features. It explains the use of C++ directives, header files, variables, data types, and the syntax required for writing C++ programs. Additionally, it covers input and output statements using the cout and cin objects for user interaction.

Uploaded by

mcaunin2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Module-1.C

This document provides an introduction to programming with a focus on C++, detailing its history, key milestones, and modern features. It explains the use of C++ directives, header files, variables, data types, and the syntax required for writing C++ programs. Additionally, it covers input and output statements using the cout and cin objects for user interaction.

Uploaded by

mcaunin2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Module 1: "Introduction to Programming" and "Input/Output Statements in C++.

"

Introduction

Programming is the process of designing and building computer programs to solve


specific problems or perform tasks. It involves writing instructions in a programming
language that the computer can understand and execute. C++ is one of the most
widely used programming languages, known for its efficiency and support for both
procedural and object-oriented programming.

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++11 (2011): Introduced smart pointers, lambda expressions, and range-based


loops.
 C++17 (2017): Added filesystem library and enhanced compile-time
programming.
 C++20 (2020): Introduced concepts, modules, and coroutines.
 C++23 (2023): Further refined the language.

Today: C++ remains a versatile, high-performance language for system programming,


games, and large-scale applications. Its ongoing updates ensure its relevance in
modern software development.

C++ Directives (#include)

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:

 <iostream>: For input and output operations.


 <cmath>: For mathematical functions.
 <string>: For string manipulation.

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:

int age = 25;


float height = 5.9;
char grade = 'A';

Data Types

C++ supports various data types to define variables. Common data types include:

 int: For integers (e.g., 10, -5).


 float: For decimal numbers (e.g., 3.14).
 char: For single characters (e.g., 'A').
 bool: For boolean values (true or false).
 string: For strings (e.g., "Hello, World!").

Syntax and Format

The syntax and format of C++ refer to the rules and structure that a program must
follow. Key components of C++ syntax include:

 Statements must end with a semicolon (;).


 Curly braces {} define blocks of code.
 Functions like main() are used as entry points.
Example of a simple program:

#include <iostream>
using namespace std;

int main() {
cout << "Hello, World!";
return 0;
}

Input/Output Statements in C++

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;
}

The endl manipulator moves the cursor to the next line.

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;
}

You might also like