0% found this document useful (0 votes)
32 views8 pages

Pwet Ni Charlim

The document provides an overview of C++, its history, features, and the development by Bjarne Stroustrup, highlighting its advantages over C and its compatibility. It also covers flowcharting basics, including symbols and their importance in illustrating processes, as well as fundamental data types and variable management in C++. Additionally, it explains operators used in C++ for assignment, arithmetic, relational, and logical operations.

Uploaded by

mdrruiz
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)
32 views8 pages

Pwet Ni Charlim

The document provides an overview of C++, its history, features, and the development by Bjarne Stroustrup, highlighting its advantages over C and its compatibility. It also covers flowcharting basics, including symbols and their importance in illustrating processes, as well as fundamental data types and variable management in C++. Additionally, it explains operators used in C++ for assignment, arithmetic, relational, and logical operations.

Uploaded by

mdrruiz
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/ 8

REVIEWER FOR PROGRAMMING

History of C++ (C with Classes)


 C++ is a portable language that works on multiple platforms such as Windows, Mac OS, Linux, and
Unix.
 Developer: Bjarne Stroustrup (Danish computer scientist).
o C++ was created to improve upon the C programming language, which was popular for
developing the UNIX operating system.
o C is derived from the B programming language, which evolved from BCPL.
 C++ originated as C with Classes and officially became C++ in 1983, with the ++ operator
symbolizing an increment.
 The international standard for C++ was established in 1998.

Bjarne Stroustrup: The C++ Developer


 Birth: December 30, 1950 (Danish scientist).
 Education:
o Master's in Mathematics, Aarhus University (1975).
o PhD in Computer Science, Cambridge University (1979).
 Career:
o Visiting professor at Columbia University.
o Managing Director at Morgan Stanley, New York.

History of Programming Languages


Year Language Developer Location

1963 CPL University of London & Cambridge Cambridge University

1967 BCPL Martin Richards Cambridge University

1958-68 ALGOL John Backus (US), Peter Naur, Van Wijngaarden (Europe) US & Europe

1970 B Ken Thompson Bell Labs, US

1972 C Dennis Ritchie Bell Labs, US

1983 C++ Bjarne Stroustrup AT&T, US

What is C++?
 C++ is an extension of the C language, inheriting its rich operator set and portability across systems.
 Compatible with C programs, maintaining compatibility was a primary design goal.
 Advantages of C++ over C:
o Strong Typing: Improved type safety.
o Object-Oriented Programming: Introduces classes and objects.
o General Purpose Language: C++ can replace C in general-purpose programming.

Features of C++
 Portability: Programs can run on various machines and systems.
 Compatibility: C++ compilers can handle existing C code.
 Object-Oriented Programming (OOP): Support for classes and objects.
 Rich Operator Set: Inherits from C, which includes a variety of operators.
 Main Function: Every C++ program must have a main() function.

Flowchart Overview
 A flowchart is a graphical representation of a process, showing the steps in sequence using
specialized symbols.
 It provides a visual guide, helping people follow a process logically from beginning to end.
 Applications: Used to model data, instructions, processes, information, and workflows.

Importance of Flowcharts
 Flowcharts help illustrate complex processes in an easy-to-understand visual form.
 Useful as a business tool for effective and efficient communication of process steps.

Flowcharting Symbols
Here are key symbols used in flowcharts:

Symbol Name Description

⬦ Terminal Used for START (beginning) and STOP (ending) of the flowchart.

⬒ Initialization Prepares or initializes memory for data processing.


Symbol Name Description

☐ Input/Output Defines when to request input from the user or output a value.

⬠ Process Represents steps for assigning values or mathematical computations.

➔ Flowlines Shows the sequence or flow of the process steps with directional arrows.

● On-Page Connector Connects parts of the flowchart on the same page, avoiding tangled lines.

⧫ Off-Page Connector Connects parts of the flowchart across different pages, for clarity.

◇ Decision Represents a conditional decision using relation operators (yes/no paths).

⊞ Pre-Defined Process Used to indicate a function or a group of statements performing a task.

📝 Comment Adds a note or comment to explain certain parts of the flowchart.

Key Takeaways
 Flowcharts help simplify processes by using visual symbols.
 Flowlines show the logical sequence, while connectors help avoid confusion in complex diagrams.
 Decision and Process symbols are crucial for mapping out logic and operations.

Basic Data Types


Data types define the type and size of data stored in variables.
Data Type Size Description

int 4 bytes Stores whole numbers without decimals (e.g., 123, -123).

float 4 bytes Stores fractional numbers with up to 7 decimal digits (e.g., 19.99).

double 8 bytes Stores fractional numbers with up to 15 decimal digits (e.g., 19.9999).

boolean 1 byte Stores true or false values.

char 1 byte Stores a single character, letter, or ASCII value (e.g., 'a', 'B').

Variables and Data Types


 Variables: Containers used to store data values.
 Common Variable Types:
o int: Stores integers (e.g., 123, -123).
o float: Stores floating-point numbers with decimals (e.g., 19.99).
o double: Stores floating-point numbers with more precision (e.g., 19.99999).
o char: Stores a single character (e.g., 'A').
o string: Stores text (e.g., "Hello World").
o bool: Stores true or false.

Rules for Naming Variables (Identifiers)


 Names can contain letters, digits, and underscores.
 Must begin with a letter or an underscore (_).
 Case-sensitive: myVar and myvar are different.
 Cannot contain special characters like !, #, %, etc.
 Reserved words (e.g., int, double) cannot be used as variable names.

Declaring Variables
To declare a variable, specify the data type followed by the variable name:
int myNum = 15;
 Syntax: type variableName = value;
Example:
#include <iostream>
using namespace std;

main() {
int myNum = 15;
cout << myNum; // OUTPUT: 15
}

Modifying and Reassigning Variables


You can declare a variable without assigning a value and assign it later:
Example:

#include <iostream>
using namespace std;

main() {

int myNum;

myNum = 15;

cout << myNum; // OUTPUT: 15

Overwriting values:
#include <iostream>
using namespace std;
main() {
int myNum = 15;
myNum = 10;
cout << myNum; // OUTPUT: 10
}

Other Data Types Demonstration


int myNum = 5; // Integer
double myFloatNum = 5.99; // Floating-point number
char myLetter = 'D'; // Character
string myText = "Hello"; // String
bool myBoolean = true; // Boolean (true/false)

Displaying Variables
The cout object with the << operator is used to display variables.
Example:
#include <iostream>
using namespace std;

main() {
int myAge = 35;
cout << "I am " << myAge << " years old."; // OUTPUT: I am 35 years old.
}

Adding Variables
To add variables, use the + operator:
#include <iostream>
using namespace std;

main() {
int x = 5;
int y = 6;
int sum = x + y;
cout << sum; // OUTPUT: 11
}

Declaring Multiple Variables


You can declare multiple variables of the same type in one line:
#include <iostream>
using namespace std;

main() {
int x = 5, y = 6, z = 50;
cout << x + y + z; // OUTPUT: 61
}

C++ Identifiers
Identifiers are unique names for variables. Use descriptive names to improve readability and maintainability.
Example:
#include <iostream>
using namespace std;

main() {
int minutesPerHour = 60; // Good name
int m = 60; // Not descriptive
cout << minutesPerHour << "\n"; // OUTPUT: 60
cout << m; // OUTPUT: 60
}
C++ Constants
To prevent modification of a variable, use the const keyword:
#include <iostream>
using namespace std;

main() {
const int myNum = 15;
// myNum = 10; // Error: Assignment of read-only variable
}

Example of constants:
#include <iostream>
using namespace std;

main() {
const int minutesPerHour = 60;
const float PI = 3.14;
cout << minutesPerHour << "\n"; // OUTPUT: 60
cout << PI; // OUTPUT: 3.14
}

1. Assignment Operators
Assignment operators assign values to variables.
Operator Description Example

= Simple assignment C = A + B assigns A + B to C

+= Add and assign C += A is equivalent to C = C + A

-= Subtract and assign C -= A is equivalent to C = C - A

*= Multiply and assign C *= A is equivalent to C = C * A

/= Divide and assign C /= A is equivalent to C = C / A

%= Modulus and assign C %= A is equivalent to C = C % A

2. Arithmetic Operators
Used for common mathematical operations.
Operator Name Example

+ Addition C = A + B;

- Subtraction C = A - B;

* Multiplication C = A * B;
Operator Name Example

/ Division C = A / B;

% Modulus C = A % B;

++ Increment ++A;

-- Decrement --A;

3. Relational or Comparison Operators


Used to compare two values.

Operator Description Example

== Equal to (A == B)

!= Not equal to (A != B)

> Greater than (A > B)

< Less than (A < B)

>= Greater than or equal to (A >= B)

<= Less than or equal to (A <= B)

4. Logical Operators
Used to combine multiple conditions.
Operator Description Example

&& Logical AND (A && B)

|| Logical OR `(A

! Logical NOT !A

You might also like