 
 Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C++ Articles - Page 483 of 719
 
 
			
			603 Views
In this tutorial, we will be discussing a program to convert decimal fraction to a binary number.For this we will be provided with a decimal fraction and integer ‘k’. Our task is to convert the given decimal fraction into its binary equivalent upto the given ‘k’ digits of decimal precision.Example Live Demo#include using namespace std; //converting decimal to binary number string convert_tobinary(double num, int k_prec) { string binary = ""; //getting the integer part int Integral = num; //getting the fractional part double fractional = num - Integral; //converting integer to binary while (Integral) ... Read More
 
 
			
			367 Views
In this tutorial, we will be discussing a program to convert a binary search tree to a min heap.For this we will be provided with a binary search tree. Our task is to convert the given binary search tree into a min heap such that following the condition of the binary search tree when elements are compared with themselves.Example Live Demo#include using namespace std; //node structure of BST struct Node { int data; Node *left, *right; }; //node creation struct Node* getNode(int data) { struct Node *newNode = new Node; newNode->data = data; newNode->left = ... Read More
 
 
			
			569 Views
In this tutorial, we will be discussing a program to convert a binary search tree to a max heap.For this we will be provided with a binary search tree. Our task is to convert the given binary search tree into a max heap such that following the condition of the binary search tree when elements are compared with themselves.Example Live Demo#include using namespace std; //node structure of BST struct Node { int data; Node *left, *right; }; //node creation struct Node* getNode(int data) { struct Node* newNode = new Node; newNode->data = data; newNode->left = ... Read More
 
 
			
			362 Views
In this tutorial, we will be discussing a program to convert an array into zig-zag fashion.For this we will be provided with an array containing distinct elements. Our task is to rearrange the elements of the given array in a zig zag fashion with greater and smaller elements alternatively as compared to the previous element.Example Live Demo#include using namespace std; //converting into zig-zag fashion void convert_zigzag(int arr[], int n) { //flag denotes the greater or smaller relation bool flag = true; for (int i=0; i arr[i+1]) swap(arr[i], arr[i+1]); } else ... Read More
 
 
			
			199 Views
In this tutorial, we will be discussing a program to convert an array to its reduced form using vector of pairs.For this we will be provided with an array. Our task is to convert the given array in its reduced form such that it only contains elements ranging from 0 to n-1.Example Live Demo#include using namespace std; //converting array to its reduced form void convert(int arr[], int n){ //creating a vector of pairs vector v; //putting elements in vector //with their indexes for (int i = 0; i < n; i++) ... Read More
 
 
			
			142 Views
In this tutorial, we will be discussing a program to convert an array to its reduced form using hashing.For this we will be provided with an array. Our task is to convert the given array in its reduced form such that it only contains elements ranging from 0 to n-1.Example Live Demo#include using namespace std; //converting array to its reduced form void convert(int arr[], int n){ // copying the elements of array int temp[n]; memcpy(temp, arr, n*sizeof(int)); sort(temp, temp + n); //creating a hash table unordered_map umap; int val = 0; for ... Read More
 
 
			
			374 Views
In this tutorial, we will be discussing a program to convert an array to a circular doubly linked list.For this we will be provided with an array. Our task is to take the elements of the array and get it converted into a circular doubly linked list.Example Live Demo#include using namespace std; //node structure for doubly linked list struct node{ int data; struct node *next; struct node *prev; }; //node creation struct node* getNode(){ return ((struct node *)malloc(sizeof(struct node))); } //printing the list int print_list(struct node *temp){ struct node *t = temp; if(temp == NULL) ... Read More
 
 
			
			367 Views
In this tutorial, we will be discussing a program to convert an arbitrary binary tree to a tree that holds children sum property.For this we will be provided with a binary tree. Our task is to convert it into the binary tree that follows the children sum property. But the restriction is that we can only increment the values present in the nodes, neither can change the structure of the tree or decrement values in the node.Example Live Demo#include #include using namespace std; //node structure for binary tree class node{ public: int data; node* left; node* right; ... Read More
 
 
			
			103 Views
In this tutorial, we will be discussing a program to convert all substrings of length ‘k’ from base ‘b’ to decimal.For this we will be provided with a string of some certain length. Our task is to take the substrings from the given string of size ‘k’ and get it converted into the decimal numbers from being in base ‘b’.Example Live Demo#include using namespace std; //converting the substrings to decimals int convert_substrings(string str, int k, int b){ for (int i=0; i + k = 0; i--){ sum = sum + ((sub.at(i) - '0') * pow(b, ... Read More
 
 
			
			2K+ Views
As we know that in C/C++ we require float and double data type for the representation of Floating point numbers i.e the numbers which have decimal part with them.Now on the basis of precision provided by both of these data types we can differentiate between both of them.In simple words it could be state that double has 2x more precision as compare than float which means that double data type has double precision than as compare to that of float data type.In terms of number of precision it can be stated as double has 64 bit precision for floating point ... Read More