Skip to main content

Posts

Expressions and Operators in C++.

An Expression is composed one more or more operand and operations to be applied on them.  In C++ Operand can by anything like an integer, a float, or a array and the operations applied to the operands are represented by Operators .  We can classify the Operators in three Categories - Unary Operators. Binary Operators. Ternary Operator. ( will be discussed at last ) (Don't try to relate anything about Binary Operators and Binary Numbers.) 1. Unary Operators - Unary operators are those which act on only one operand.(Do you know any operators like this? YES, you have seen them previously), The address of (ampersand (&)) operators and de-reference (*) operator. These two operators are Unary operators, We have used them like -  #include<iostream> using namespace std; int main () { int a = 10 ; // Initialization of variable 'a' int *b = &a; // Storing address using unary operators '*' and '&' in b return 0 ; } You c

C++ User defined Data Types.

I had explained Built-in and Derived Data types in previous blogs. Now, Let's resume our topic from User Defined Data types. Simple definition - User defined data types are the data types which the User define by himself/herself. We need these data types because there are certain cases when the pre-defined data types won't help us, e.g. think of a list, which contain every information about every particular student learning in a school. Like Student name, Student IDs, Student class, Student section etc. You can think of using arrays, but arrays can only contain one field of data of built-in datatypes like int, char etc. Which is not sufficient. Now, We will discuss the following topics -  Class. Structures. Enumeration. Union. So, let's start our discussion. Classes Class is a data type present in C++, but not in C. Classes can be considered as a mechanism that allows us to create new types(of data), and we can declare and use objects of that type. A class definition cons

C++ Arrays, functions, pointers and references.

In the previous section, I have discussed about  Built-in Data Types in depth. Now, let's taste the flavors of Variables and literals, with a in depth introduction. Variables A Variable provide us with named memory storage, i.e. a storage in our so called RAM with a particular name (usually we give the name), We can write, modify and use this storage with the help of associated name (variable). Each variable in C++ is associated with some specific data type, like Built-in data types that we previously discussed.  There are mainly two values that are associated with any variable. RValues. LValues. Let's see what all these means. RValues - We know that a variable has some data associated with it, and we can read, write this data, this data that we read and write is termed as RValue. You can also think of RValues as Read Values or as a simple trick from me to you, you can think of as the right side values of assignment opeartor(=) . LValues - We Also know that these variables a

C++ Built-in Data types.

Before diving into definition of various Data Types, let's first discuss something about memory. Below is the block diagram of memory(ram) where all the data is temporarily stored before execution. Memory. The lower area of this diagram is referred as Low Memory address and upper area of this diagram is referred as High Memory address. Now let's briefly discuss each of the segments, one by one. Code Segment - The segment of memory where the text or code or your file is stored temporarily is referred as code segment. For example the main function, the function that we defined etc. Data Segment  - Data segment is of two types  Initialized data segment or simply data segment - The variables that are declared and initialized in our program are stored here. Uninitialized data segment .- The variables that are just declared or have value zero and not in use are stored here. Heap - Heap is a storage where generally dynamic memory allocation takes place with the help of pointers. If

Creating and executing c++ program.

In this slide we will discuss the following things. Creating an C++ file. Writing a Program and learning every aspect of its execution like. compilation, assembling and linking of library functions. Creating C++ File You should skip to " Your First Code ", if you know how to do this .😉 C++ program is nothing but a file with extension ".cpp". Creating a C++ file is not difficult. You can create it in anyway you like, I gave a simple way for creating. (Note - If you have not installed c++ compiler in your computer. Then, to run the c++ files, you must install  the compiler first or you can use some online c++ compiler like onlinegdb ) Your First Code Now, start typing the following code in your ".cpp" that you created. (This is also called as source code and you can consider it as the basic template for your c++ program, but I will progressively introduce more things that you can add to your c++ program). 1 2 3 4 5 6 #include<iostream> int main ()