Chandu yadav has Published 1091 Articles

How do I declare a two-dimensional array in C++ using new?

Chandu yadav

Chandu yadav

Updated on 11-Feb-2020 11:07:10

2K+ Views

A dynamic 2D array is basically an array of pointers to arrays. So you first need to initialize the array of pointers to pointers and then initialize each 1d array in a loop.example#include using namespace std; int main() {    int rows = 3, cols = 4;    int** ... Read More

How do you set, clear, and toggle a bit in C/C++?

Chandu yadav

Chandu yadav

Updated on 11-Feb-2020 10:52:13

8K+ Views

You can set clear and toggle bits using bitwise operators in C, C++, Python, and all other programming languages that support these operations. You also need to use the bitshift operator to get the bit to the right place.Setting a bitTo set a bit, we'll need to use the bitwise ... Read More

Why is not sizeof for a struct equal to the sum of sizeof of each member in C/C++?

Chandu yadav

Chandu yadav

Updated on 11-Feb-2020 10:37:42

253 Views

The difference between sizeof for a struct and the sum of sizeof of each member of that struct is due to byte padding and alignment. Every data type in C/C++ has a alignment requirement. A processor will have processing word length of its architecture. On a 32 bit machine, the ... Read More

How can we combine functions in MySQL?

Chandu yadav

Chandu yadav

Updated on 10-Feb-2020 10:43:23

580 Views

Combining of functions in MySQL is quite possible by providing a function as the argument of other function. It is also called nesting of functions. To understand it, consider some examples belowmysql> Select UPPER(CONCAT('www.', 'tutorialspoint', '.com'))As Tutorials; +------------------------+ | Tutorials              | +------------------------+ | WWW.TUTORIALSPOINT.COM ... Read More

How can MySQL SUBSTRING() function be used with FROM and FOR keywords?

Chandu yadav

Chandu yadav

Updated on 10-Feb-2020 07:46:15

197 Views

The syntax of SUBSTRING() function using FROM and FOR keywords is the standard MySQL syntax.SyntaxSUBSTRING(str FROM pos FOR len)Here,  str is the string from which substring would be returned.Pos is the starting position of substring.Len is the length of substring i.e. the total number of characters fetched from str.Examplemysql> Select ... Read More

How can we split an IP Address into four respective octets by using MySQL SUBSTRING_INDEX() function?

Chandu yadav

Chandu yadav

Updated on 10-Feb-2020 07:11:38

951 Views

Suppose we have a table named ‘ipaddress’ which contains the IP addresses as its values in column ‘IP’ as follows −mysql> Select * from ipaddress; +-----------------+ | ip              | +-----------------+ | 192.128.0.5     | | 255.255.255.255 | | 192.0.255.255   | | 192.0.1.5 ... Read More

How can we replace all the occurrences of a substring with another substring within a string in MySQL?

Chandu yadav

Chandu yadav

Updated on 07-Feb-2020 10:37:00

366 Views

MySQL REPLACE() function can replace all the occurrences of a substring with another substring within a string.SyntaxREPLACE(str, find_string, replace_with)Here Str is a string which have the substring.Find_string is a substring which is present one or more times within the strung str.Replace_with is a substring which will replace every time it finds ... Read More

How can I use another MySQL function/s with REPEAT() function?

Chandu yadav

Chandu yadav

Updated on 07-Feb-2020 10:09:17

122 Views

Suppose if we want to make the output of REPEAT() function more readable then we can use another function/s with it. For example, if we want to add space or some other character between the repeated values then we can use CONCAT() function.Examplemysql> Select REPEAT(CONCAT(' *', Subject, '* '), 3)AS ... Read More

How can I use MySQL OCTET_LENGTH() function to count the number of characters stored in a data column?

Chandu yadav

Chandu yadav

Updated on 07-Feb-2020 06:39:43

111 Views

We need to pass the column name as the argument of OCTET_LENGTH() function to count the number of characters stored in a data column. It displays the number of characters when referenced in SELECT clause. It can also be used as comparison value to decide whether or not the row ... Read More

How MySQL SUM() function evaluates if it got the column, having character data type, as its argument?

Chandu yadav

Chandu yadav

Updated on 07-Feb-2020 05:43:43

159 Views

MySQL SUM() function will return 0, rather than NULL, along with a warning on getting the character type column as its argument. Following example using data from table named ‘Social’ will illustrate it −Examplemysql> Select * from Social; +------+-------+ | Id   | Name  | +------+-------+ | 100  | ... Read More

Advertisements