Conversions

In this, we will learn about the conversions. First two conversions viz. Binary to Decimal and Decimal to Binary are explained in detail and remaining two conversions viz. Decimal to Hexadecimal and Hexadecimal to Decimal are almost same as first two but with small difference. In all the conversions, we will take one number and convert in to another. Binary to DecimalBinary number is represented with 0 and 1. Binary Number: 0110 0011 Rightmost bit of binary number is LSB i.e. Least Significant bit and leftmost bit is MSB (Most…

IPv4 Address

IPv4 Address consist of 4 numbers separated by dot(.). Each number ranges from zero to 255. Each number is an octet (each octet is of 8 bit) and that is why maximum range of each number is 255. Since each Number is an octet and there are 4 numbers in IPv4 address so IPv4 Address is a 32 bit Address Example of IPv4 Address: 10.8.12.9 Every device like computer, printer or router is assigned with IPv4 Address in order to uniquely identify in the network.IPv4 address divided in to two…

Call Pentaho Job using Batch Script

In this post, I will discuss about the “How to call the Pentaho Job in the local Machine which is windows” . To put it differently, call the Pentaho Job using batch script. Below is the sample code of the batch script. call <local_Path>\data-integration\kitchen.bat /file:<Local-Path>\Pipe-delimited-file-variables.kjb In above command, I have mentioned Path of the kitchen.bat file and then Path of the Pentaho job along with Job Name.Below is the ETL code of above Job. This job does a very simple part to load the pipe delimited file to a Table.…

Queue using stack

Let us understand how to prepare queue using two stacks When we say we have to prepare queue using stack that means all the operations of stack should be used to get the queue functionality. Queue has FIFO property i.e. First-In First-Out i.e. element which is inserted first , same element should be removed or pop first. Consider that we have two stacks s1 and s2. Initially both the stacks are empty. Here we have used Stack Using Linked List. When we push any data in to stack, we have…

nullptr

Let us understand the need of nullptr with help of an example. #include <iostream>using namespace std;class base {public: void display(int num) { cout << “Integer display: “ << num << endl; } void display(char* ptr) { cout << “ptr display: “ << ptr << endl; }}; int main() { base b; b.display(NULL); return 0; } The above code will not compiled. Below error will come: “In function int main():     15:15: error: call of overloaded display(NULL) is ambiguous            b.display(NULL); 15:15: note: candidates are:  …

auto keyword

Let us understand the usage of auto keyword with the help of an example. #include <iostream>using namespace std;int main(){ auto i = 10; auto d = 7.5; cout <<  “Integer and double: ” << i << “ “ << d << endl; return 0;} Above code can be compiled using -std=c++11 flag. Here, we have not defined the type for variable i and d.  When we initialize the variable at the time of declaration, compiler can identify or deduce the type for it. Based on this, C++11 came with the…

GET HIERARCHICAL VALUES PRESENT IN SAME COLUMN OF A TABLE

Lets discuss about the parent and child relationship present in the same column of a table. That means both exists in the same column and there is always a identifier which says whether a record belongs to parent value or it belongs to child value. See the below data .As it is clearly seen from the data, parent and child record can be easily identified from column c1. Here , we need to apply self join to get parent and child values in the same row. See the below Query.…

Stack Using Linked List

Let us see in the below program how stack can be implemented using Linked List. #include <iostream>using namespace std;typedef struct node{ int data; struct node* next; }Node;class stack{private: Node* head;public: stack() { head = NULL; } ~stack() { while (NULL != head) { Node* temp = head; head = head ->next; delete temp; } } void push(int data) { Node* temp = new Node; temp->data = data; if (NULL == head) { head = temp; head->next = NULL; return; } temp->next = head; head = temp; } int pop() {…

Stack using fixed size array

Stack is one of the data structure that uses LIFO (Last In First Out) or FILO (First In Last Out) property i.e. element which is stored in last, will be out (read) first.Real life example of stack is stack of plates. Last plate put over the plates is the first plate that is removed or used. #include <iostream>using namespace std;const int MAX_INDEX = 50;  // Maximum index of array.const int MIN_INDEX  = -1; // Minimum index  of array.class stack{private: unsigned int arr[MAX_INDEX]; int top;public: stack() { top = MIN_INDEX; }…

Initializer_list

Let us understand the concept of initializer_list with the help of an example: #include <iostream>#include <vector>#include <initializer_list>using namespace std;#define MAX 10class array{public: array(std::initializer_list<unsigned int> list) { index = 0; for(auto item: list) { arr[index++] = item; } cout  << “C’tor” << endl; } void display() { for (unsigned int i = 0; i < index; ++i) { cout << arr[i] << endl; } }private: unsigned int arr[ MAX]; unsigned short index;};int main(){ array arrObj = {0,1,5,7,8}; arrObj.display(); vector <unsigned int> v = {5,8,9,10,20}; cout << “Entries in vector: ” <<…