Posts

Singly, Doubly and Circular Linked List

Image
So far, we have seen the implementation of Linked List. The Link List we implemented in the Lined List article was actually Singly Lined List. There is slightly difference between Singly, Doubly and Circular Linked List. We will see the difference and the importance of each in detail in this article.  Singly Linked List: In singly linked list, we keep head node in our linked list class. This head node is actually the starting point of our linked list. As shown: The above Figure shows the representation of Singly Linked List. We have a head node in our linked list class, it is the starting point of our linked list. Every node has some data and next pointer of type Node, that point to the next node of the list. Now I will tell you what is doubly linked list an why we need it. Doubly Linked List: In node of singly linked list, we have only one pointer of type node but in doubly linked list we have two pointers of type node. They are generally named as next and previous. The next point...

Linked List

Linked List: So far, we have studied arrays and pointers. We see, whenever we make an arrays we have to declare its size. i.e my_array[10] or some thing like my_array[10][10] (2D array) . We solve this problem by using pointers. We used to ask size of array from user and then, make dynamic memory of that size. We did something like int* my_array = new int[size] . Where size is given by user. Now let discuss what is its demerit of using this process of creating dynamic memory. Let say, user want to make array of size 20. Using dynamic memory we will create array of size 20 easily, but now let say, user wants to add one more item to this array. i.e he/ she wants to grow this array. What we can do using this strategy, we will make an array of size 21 or more then, transfer the data of previous array the delete the previous array. What's wrong with using this type of implementation? Lets consider, we have made an array of size 10,000,000. Now we want to grow this array to 10,000,001....

C++ Programs Examples

  How to swap two variables in c++? We can swap two variables very easily in c++. There are two methods of swap. First method:    By using a temporary variable. Second method:    Without using temporary variable. Lets start with the first method. We use a third variable which is called temporary variable and represented as temp.  The code is very simple and is given below: #include<iostream> using namespace std; void main() { int a = 5, b = 10; cout << "a= " << a << "  " << "b= " << b << endl; int temp = a; a = b; b = temp; cout << "After swap:" << endl; cout << "a= " << a << "  " << "b= " << b << endl; system("pause"); }

C++ Programs Examples

 We can take input and output from user very easily. For input we use cin>>   and for output we use cout<< .  Assignment: Write a code/program that takes age of the user as input and print out  "You are age years old". For example if user enter his age 19 then your program should print "You are 19 years old". Dry Run: What is your age? 19 You are 19 years old.

Hello World Program

This is very simple program. You can write it easily. The exact code for this program is given below.  #include <iostream> using namespace std; void main() {   cout<<"Hello World!"<<endl;   system ("pause"); } Explanation: In the first line ,  #include <iostream>  it is c++ built in library. This library provides some functions that are very useful. You will understand it gradually, when you will study functions and classes in c++. As a beginner, it is enough for you to remember that it is a built in library and you have to include it in every code or program. The second line   using namespace std;  make it easy for you to use input stream cin>>  , output streams cout<<  , and other function like endl  easily. If you do not use it or if you want to skip it then you will have to write std::cout<< instead of only cout<<  , std::cin>> instead of cin>> and std::endl instead...

Data Types in C++

Data Type: Data type mean different types or form of data. Example: Integer, Float, Character, String etc are different data types. Their short form is used in programming to initialize any data member. Data Type                                                  Representation in C++ Integer                                                               int Float                                                                  float Character                              ...

How To Earn Money Online

 There are different ways through which you can earn money online with out any investment. Here, I will discuss almost all the possible ways through which you can earn money online. Here, list of different methods of earning money online along with their introduction is given below: 1) Earn money through YouTube channel: As you all knows that the world is moving towards digital media. The people prefer everything on their mobile phone. The trend of watching cable Television and cable channels are reducing day by day. Now a days, it is good to launch a YouTube channel and earn money through it. It is very simple to create a YouTube channel. If you have G-mail account, you can make your YouTube channel through it. It will take almost 2-3 months hard work to make your YouTube channel successful. Now, I will also tell you how to make your YouTube channel successful. First thing that you should know is video editing. There are a lot of software like adobe which will help you in this reg...