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
Server Side Programming Articles - Page 1894 of 2646
165 Views
In this tutorial, we will be discussing a program to find the numbers having ‘d’ digits with 0 as a digit.For this we will be provided with a number ‘d’. Our task is to count and print the number of positive integers having ‘d’ digits and 0 as one of their digit.Example Live Demo#include using namespace std; //counting the number of 'd' digit numbers int count_num(int d) { return 9*(pow(10,d-1) - pow(9,d-1)); } int main(){ int d = 1; cout
184 Views
In this tutorial, we will be discussing a program to find the cost of making a string panagram.For this we will be provided with an array of integers. Our task is to convert the given string into a panagram and calculate the cost of doing that with the help of the array provided with the costs of adding characters.Example Live Demo#include using namespace std; //calculating the total cost of //making panagram int calc_cost(int arr[], string str) { int cost = 0; bool occurred[26] = { false }; for (int i = 0; i < str.size(); i++) ... Read More
144 Views
In this tutorial, we will be discussing a program to find the cost to balance the parentheses.For this we will be provided with a sequence of brackets. Our task is to balance those parentheses in the equation by shifting their position by one and print -1 if balancing them isn’t possible.Example Live Demo#include using namespace std; int costToBalance(string s) { if (s.length() == 0) cout
204 Views
In this tutorial, we will be discussing a program to find the cost of painting n*m grid.For this we will be provided with two integers n and m. Our task is to calculate the minimum cost of painting a n*m grid is the cost of painting a cell is equal to the number of painted cells adjacent to it.Example Live Demo#include using namespace std; //calculating the minimum cost int calc_cost(int n, int m){ int cost = (n - 1) * m + (m - 1) * n; return cost; } int main(){ int n = 4, m = 5; cout
203 Views
In this tutorial, we will be discussing a program to correct the random pointer in a doubly linked list.For this we will be provided with a doubly linked list with one node having a random pointer. Our task is to rectify the element to whom the pointer should be pointing i.e the element next to it.Example Live Demo#include using namespace std; //node structure for doubly linked list struct node { int data; node* next; node* prev; }; //new node creation node* newNode(int data){ node* temp = new node; temp->data = data; temp->next = temp->prev ... Read More
1K+ Views
Array is a data structure that store data in the contagious memory location.Declaring arraysDeclaring arrays is done by the following syntax : int 1D[] - for 1-D array int 2D[][] - for 2-D arrayIf you initialize an array with lesser number of elements, rest are initialized with 0.Memory address of elements of the array1-D array : address[i] = baseAddress + i*size 2-D array (row major) : address[i][j] = baseAddress + (i*n + j) * sizeNow, let’s see some practice problemPredict the output of the following code snippetint arr[5] = {6, 9}; for(int i = 0; i
722 Views
String is an important part of programming. Strings are the array of character types. In competitive exams like GATE also it is an important topic. So let’s discuss some key points about string and then we will proceed to some questions that will help you clear your concepts about string.String in a programming language can be stored in two different ways. They are using character array (char str[size]) and using a pointer that will point to the string (char * ch = “Hello”). There are some important things related to the use of the character array and pointer to a ... Read More
10K+ Views
Time complexity of any algorithm is the time taken by the algorithm to complete. It is an important metric to show the efficiency of the algorithm and for comparative analysis. We tend to reduce the time complexity of algorithm that makes it more effective.Example 1Find the time complexity of the following code snippetsfor(i= 0 ; i < n; i++){ cout
8K+ Views
Precision of floating point numbers is the accuracy upto which a floating point number can hold the values after decimal. For example, 10/6 = 1.6666666… these have recurring decimals which can take infinite memory spaces to be stored. To avoid memory overflow in such cases the compiler set a precision limit to the number. For float values in C++, the precision is set to 6-7 digit after that if the decimal recurs it will discard the value. So, to avoid any major losses when this discarding takes place there are methods and libraries that support the precision is float values. ... Read More
2K+ Views
Identifier is the name given to an entity in programming to identify it in the program.Generally, identifiers are created by the programmer for efficient working but there are some predefined identifiers that are inbuilt in programming. For example, cout, cin, etc.Here, we will see one of these predefined identifiers of C programming language which is __func__.The formal definition of __func__ is −“The identifier __func__ shall be implicitly declared by the translator as if, immediately following the opening brace of each function definition, the declarationstatic const char __func__[] = “function-name”;appeared, where function-name is the name of the lexically-enclosing function.”C program The ... Read More