
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
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
Found 7197 Articles for C++

193 Views
In this tutorial, we will be discussing a program to convert the undirected graph into a directed graph such that there is no path of length greater than 1.For this we will be provided with an undirected graph. Our task is to convert that graph into a direct one given no path has a length greater than 1.Example Live Demo#include using namespace std; #define N 100005 //storing the graph vector gr[N]; //storing colour of each vertex int colour[N]; vector edges; bool bip; //adding edges to the graph void add_edge(int x, int y){ gr[x].push_back(y); gr[y].push_back(x); edges.push_back(make_pair(x, y)); } ... Read More

381 Views
In this tutorial, we will be discussing a program to convert the string into palindrome string by changing only one character.For this we will be provided with a string. Our task is to convert the given string into a palindrome by changing only one character.Example Live Demo#include using namespace std; //checking if conversion to palindrome //is possible bool if_palindrome(string str){ int n = str.length(); //counting number of characters //to be changed int count = 0; for (int i = 0; i < n/2; ++i) if (str[i] != str[n - i - 1]) ++count; return (count

806 Views
In this tutorial, we will be discussing a program to convert the ASCII value sentence to its equivalent string.For this we will be provided with a string containing the ASCII codes. Our task is to convert the given string into the equivalent characters and print it back.Example Live Demo#include using namespace std; //converting the ASCII sequence into //character string void convert_ASCII(string str, int len){ int num = 0; for (int i = 0; i < len; i++) { //appending the current digit num = num * 10 + (str[i] - '0'); //checking if number is within range if (num >= 32 && num

265 Views
In this tutorial, we will be discussing a program to convert the array such that the GCD of the array becomes one.For this we will be provided with an array and a positive integer k. Our task is to convert the array elements such that the GCD of elements is 1 while only dividing the array elements by k any number of times until the element is less than k.Example Live Demo#include using namespace std; //calculating the GCD of array int calculate_gcd(int* arr, int n){ int gcd = arr[0]; for (int i = 1; i < n; i++) ... Read More

261 Views
In this tutorial, we will be discussing a program to convert ternary expression to a binary tree.For this we will be provided with a ternary expression. Our task is to convert the given expression in the form of a binary tree depending upon the various paths(choices) possible.Example Live Demo#include using namespace std; //node structure of tree struct Node { char data; Node *left, *right; }; //creation of new node Node *newNode(char Data){ Node *new_node = new Node; new_node->data = Data; new_node->left = new_node->right = NULL; return new_node; } //converting ternary expression into binary tree Node ... Read More

1K+ Views
In this tutorial, we will be discussing a program to convert string into Binary sequence.For this we will be provided with a string of characters. Our task is to convert each of the character into its binary equivalent and print it out spaced between for different characters.Example Live Demo#include using namespace std; //converting into binary equivalent void convert_binary(string s){ int n = s.length(); for (int i = 0; i 0){ (val % 2)? bin.push_back('1') : bin.push_back('0'); val /= 2; } reverse(bin.begin(), bin.end()); cout

285 Views
In this tutorial, we will be discussing a program to convert a singly linked list into XOR linked list.For this we will be provided with a singly linked list. Our task is to take the elements of that list and get it converted into a XOR linked list.Example Live Demo#include using namespace std; //node structure of linked list struct Node { int data; struct Node* next; }; //creation of new node Node* newNode(int data){ Node* temp = new Node; temp->data = data; temp->next = NULL; return temp; } //printing singly linked list void print(Node* ... Read More

566 Views
In this tutorial, we will be discussing a program to convert a singly linked list into circular linked list.For this we will be provided with a singly linked list. Our task is to take the elements of that list and get it converted into a circular linked list.Example Live Demo#include //node structure of linked list struct Node { int data; struct Node* next; }; //converting singly linked list //to circular linked list struct Node* circular(struct Node* head){ struct Node* start = head; while (head->next != NULL) head = head->next; //assigning start to ... Read More

739 Views
In this tutorial, we will be discussing a program to convert min heap to max heap.For this we will be provided with the array representation of the min heap. Our task is to convert that given min heap to max heap in O(n) time complexity.Example Live Demo#include using namespace std; //converting a given subtree into a heap void convert_arrayheap(int arr[], int i, int n){ int l = 2*i + 1; int r = 2*i + 2; int largest = i; if (l < n && arr[l] > arr[i]) largest = l; if (r ... Read More

2K+ Views
In this tutorial, we will be discussing a program to convert hexadecimal value string to ASCII value string.For this we will be provided with a string with some hexadecimal values. Our task is to get that hexadecimal value and convert it into equivalent ASCII values.Example Live Demo#include using namespace std; string convert_ASCII(string hex){ string ascii = ""; for (size_t i = 0; i < hex.length(); i += 2){ //taking two characters from hex string string part = hex.substr(i, 2); //changing it into base 16 char ch ... Read More