Programming Articles - Page 2521 of 3363

ASCII NUL, ASCII 0 (‘0’) and Numeric literal 0?

Arnab Chakraborty
Updated on 30-Jul-2019 22:30:26

7K+ Views

Here we will see the ASCII NUL, ASCII 0 and the Numeric Literal 0. The ASCII null is represented as 0x00, and zero is represented as 0x30. The ASCII NUL character is used to denote the end of the string in C or C++. When programmer used ‘0’ (character 0) it is treated as 0x30. This is a hexadecimal number. The decimal equivalent is 48. To put ASCII NUL we have to mention ‘\0’ instead of ‘0’.char asciiNul = ‘\0’; int zero = 0; char zeroChar = ‘0’;The first one is ASCII NUL, second one is numeric 0, and the third one is character 0.

How to change the position of a JSlider to horizontal/vertical programmatically in Java?

raja
Updated on 10-Feb-2020 10:48:18

420 Views

A JSlider is a subclass of JComponent class and it is similar to scroll bar which allows the user to select a numeric value from a specified range of integer values. It has a knob which can slide on a range of values and can be used to select a particular value. A JSlider can generate a ChangeListener interface and the important methods of JSlider are getMaximum(), getMinimum(), getOrientation(), getValue() and setValue(). The default position of a JSlider is horizontal and we can also set the position to vertical programmatically by selecting a menu item from a menu bar. It can generate an ActionListener interface ... Read More

Array::fill() and array::swap() in C++ STL?

Arnab Chakraborty
Updated on 30-Jul-2019 22:30:26

610 Views

In this section we will see what are the usage of array::fill() and the array::swap() in C++ STL.The array::fill() function is used to fill the array with some specified value. Let us see one example to get the idea.Example Live Demo#include #include using namespace std; main() {    array arr = {00, 11, 22, 33, 44, 55, 66, 77, 88, 99};    cout

Array::crbegin() and array::crend() in C++ STL?

Arnab Chakraborty
Updated on 30-Jul-2019 22:30:26

139 Views

Here we will see the crbegin() and crend() functions of array in C++ STL.The array::crbegin() function is used to get reverse iterator. It returns constant reverse iterator pointing to the last element of the container. This function does not take any parameter.The array::crend() function is reverse of crbegin(). This returns the iterator which is pointing the last element of the reversed iterator.Let us see some code examples to get better idea.Example Live Demo#include #include using namespace std; main() {    array arr = {00, 11, 22, 33, 44, 55, 66, 77, 88, 99};    cout

Array get() function in C++ STL?

Arnab Chakraborty
Updated on 30-Jul-2019 22:30:26

347 Views

In this section we will see the get() function of array in C++ STL. This function is used to get the ith element of the array container. The syntax is like below −Syntaxget array_nameThis function takes two mandatory parameters. The is the index parameter. It is used to point to the ith position of the array. The second argument is array_name. This is the actual array from this ith element will be taken. This function returns the ith element.Let us see one example to get the idea.Example Live Demo#include #include using namespace std; main() {    array arr = {00, 11, ... Read More

Arrange given numbers to form the biggest number?

Arnab Chakraborty
Updated on 30-Jul-2019 22:30:26

319 Views

Here we will see how to generate the biggest number by rearranging the given numbers. Suppose there are {45, 74, 23} is given, the program will find the largest number, that is 744523. So each digit will not be arranged. but the whole number will be placed to make largest number.To solve this problem, we will use the string sorting. But the comparison logic is different. The comparing function will take two numbers a and b, then concatenate them to form ab and ba. Among them which one is bigger, that is considered.AlgorithmcompareStrings(a, b)begin    ab := concatenate b with ... Read More

Argument Coercion in C/C++?

Arnab Chakraborty
Updated on 30-Jul-2019 22:30:26

2K+ Views

Here we will see about the argument coercion in C or C++. The Argument Coercion is one technique by which the compiler can implicitly convert the arguments from one type to another type. It follows argument promotion rule. If one argument is lower datatype, that can be converted into higher datatypes, but the reverse is not true. The reason is if one higher datatype is converted into a lower datatype, it may loss some data.Let us see one pyramid that can express how the implicit conversion takes place.Example Live Demo#include using namespace std; double myAdd(double a, double b){    return a+b; ... Read More

Area of triangle formed by the axes of co-ordinates and a given straight line?

Arnab Chakraborty
Updated on 30-Jul-2019 22:30:26

159 Views

Here we will see how to get the area of a triangle formed by the x and y axis and another straight line. The diagram will be look like below. The equation of the straight line is −𝑎𝑥+𝑏𝑦+𝑐=0The line is cutting the x-axis at the point B, and cutting the y-axis at the point A. The intercept form will be like below −So the x-intercept is −𝑐∕𝑎 and y-intercept is −𝑐∕𝑏 . So the area of the triangle isExample Live Demo#include #include using namespace std; double areaTriangle(double a, double b, double c){    return fabs((c*c) / (2*a*b)); } main() {   ... Read More

All reverse permutations of an array using STL in C++?

Arnab Chakraborty
Updated on 21-Feb-2025 16:30:01

335 Views

In this problem, we need to generate all reverse permutations of a given array using C++'s Standard Template Library (STL). A permutation is simply rearranging the elements of the array in every possible order. For example, with an array of three elements, there are six possible ways to arrange them. For each of these permutations, we need to reverse the order of the elements and then print the results. The goal is to first generate all possible permutations of the array, then reverse each one before displaying them. Example Scenario: Let's say we have the array {1, 2, 3}. ... Read More

All permutations of a string using iteration?

Arnab Chakraborty
Updated on 30-Jul-2019 22:30:26

890 Views

In this section we will see how to get all permutations of a string. The recursive approach is very simple. It uses the back-tracking procedure. But here we will use the iterative approach.All permutations of a string ABC are like {ABC, ACB, BAC, BCA, CAB, CBA}. Let us see the algorithm to get the better idea.AlgorithmgetAllPerm(str)begin    sort the characters of the string    while true, do       print the string str       i := length of str – 1       while str[i - 1] >= str[i], do          i := ... Read More

Advertisements