Category Archives: OOP with C++

10. LOOPS

There may be a situation when you need to execute a block of code several times. In general, statements are executed sequentially: The first statement in a function is executed first, followed by the second, and so on. Programming languages provide various control structures that allow for more complicated execution paths. A loop statement allows… Read More »

09. C++ switch statement

A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each case. Syntax The syntax for a switch statement in C++ is as follows − switch(expression) { case constant-expression : statement(s); break; //optional case constant-expression : statement(s); break;… Read More »

08. AND, OR & NOT

Logical Operators There are following logical operators supported by C++ language. Logical operators are used to determine the logic between variables or values: Operator Name Description Example &&  Logical and Returns true if both statements are true x < 5 &&  x < 10 ||  Logical or Returns true if one of the statements is… Read More »

07. C++ Conditions and If Statements

C++ supports the usual logical conditions from mathematics: Less than: a < b Less than or equal to: a <= b Greater than: a > b Greater than or equal to: a >= b Equal to a == b Not Equal to: a != b You can use these conditions to perform different actions for different decisions. C++ has the following… Read More »

01. Introduction of Computer Programming

Introduction of Computer Programming A computer is a programmable machine. This means it can execute a programmed list of instructions and respond to new instructions that it is given. Computer Programming is the process of developing and implementing various sets of instructions to enable a computer to do a certain task. Programs are written to… Read More »

02. C++ – Overview

C++ is a statically typed, compiled, general-purpose, case-sensitive, free-form programming language that supports procedural, object-oriented, and generic programming. C++ is regarded as a middle-level language, as it comprises a combination of both high-level and low-level language features. C++ was developed by Bjarne Stroustrup starting in 1979 at Bell Labs in Murray Hill, New Jersey, as an enhancement… Read More »

03. C++ – Basic Syntax

When we consider a C++ program, it can be defined as a collection of objects that communicate via invoking each other’s methods. Let us now briefly look into what a class, object, methods, and instant variables mean. Object − Objects have states and behaviors. Example: A dog has states – color, name, breed as well as… Read More »

04. C++ – Basic Input/Output

The C++ standard libraries provide an extensive set of input/output capabilities which we will see in subsequent chapters. This chapter will discuss very basic and most common I/O operations required for C++ programming. C++ I/O occurs in streams, which are sequences of bytes. If bytes flow from a device like a keyboard, a disk drive,… Read More »

05. C++ Variable Types

A variable is a name which is associated with a value that can be changed. For example when I write int num=20; here variable name is num which is associated with value 20, int is a data type that represents that this variable can hold integer values. We will cover the data types in the next tutorial.… Read More »

06. C++ – Flow Controls

When a program is run, the CPU begins execution at the top of main(), executes some number of statements, and then terminates at the end of main(). The sequence of statements that the CPU executes is called the program’s execution path (or path, for short). Most of the programs you have seen so far have been straight-line programs.… Read More »