Category: 03. C++
-
C++ Loop Types
There may be a situation, when you need to execute a block of code several number of 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…
-
Operators in C++
An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. C++ is rich in built-in operators and provide the following types of operators − This chapter will examine the arithmetic, relational, logical, bitwise, assignment and other operators one by one. Arithmetic Operators There are following arithmetic operators supported by…
-
Storage Classes in C++
A storage class defines the scope (visibility) and life-time of variables and/or functions within a C++ Program. These specifiers precede the type that they modify. There are following storage classes, which can be used in a C++ Program The auto Storage Class The auto storage class is the default storage class for all local variables. The example…
-
C++ Modifier Types
C++ allows the char, int, and double data types to have modifiers preceding them. A modifier is used to alter the meaning of the base type so that it more precisely fits the needs of various situations. The data type modifiers are listed here − The modifiers signed, unsigned, long, and short can be applied to integer base types. In addition, signed and unsigned can be applied…
-
C++ Constants/Literals
Constants refer to fixed values that the program may not alter and they are called literals. Constants can be of any of the basic data types and can be divided into Integer Numerals, Floating-Point Numerals, Characters, Strings and Boolean Values. Again, constants are treated just like regular variables except that their values cannot be modified after…
-
Variable Scope in C++
A scope is a region of the program and broadly speaking there are three places, where variables can be declared − We will learn what is a function and it’s parameter in subsequent chapters. Here let us explain what are local and global variables. Local Variables Variables that are declared inside a function or block…
-
C++ Variable Types
A variable provides us with named storage that our programs can manipulate. Each variable in C++ has a specific type, which determines the size and layout of the variable’s memory; the range of values that can be stored within that memory; and the set of operations that can be applied to the variable. The name…
-
C++ Data Types
While writing program in any language, you need to use various variables to store various information. Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. You may like to store information of various data types like character, wide character, integer,…
-
Comments in C++
Program comments are explanatory statements that you can include in the C++ code. These comments help anyone reading the source code. All programming languages allow for some form of comments. C++ supports single-line and multi-line comments. All characters available inside any comment are ignored by C++ compiler. C++ comments start with /* and end with…
-
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. C++ Program Structure Let us look at a simple code that would print the words Hello World. Let us…