We have seen falling matrix scene in different films etc. Here we will see how to write a C++ program to do like that.To solve this problem, we have to care about these steps.Define width of the matrixTwo successive characters may or may not have same amount of gap between themA certain amount of delay between printing each line to visualize the falling effect.Example#include #include #include #include #include #include const int wd = 70; //set the width of the matrix window const int flipsPerLine =5; //five flips for the boolean array 'alternate' const int sleepTime = 50; //it will take ... Read More
A save point is a logical rollback point within a transaction. When you set a save point, whenever an error occurs past a save point, you can undo the events you have done up to the created save point using the rollback() method.You can set a save point in a database using the setSavepoint() method of the Connection interface.And, you can remove/release a save point using the releaseSavepoint() method.This method accepts a Savepoint object as a parameter and removes the specified Savepoint.To release a save point −Register the driver using the registerDriver() method of the DriverManager class as −//Registering the Driver DriverManager.registerDriver(new com.mysql.jdbc.Driver());Get the ... Read More
Use $addToSet operator to update array element. Let us first create a collection with documents −> db.updateArrayDemo.insertOne( ... { ... ... "ClientDetails" : [ ... { ... "ClientName" : "John", ... "DeveloperDetails" : [ ] ... }, ... { ... "ClientName" : "Larry", ... "DeveloperDetails" : [ ] ... } ... ] ... ... Read More
An array cannot be resized dynamically in Java. One approach is to use java.util.ArrayList(or java.util.Vector) instead of a native array.Another approach is to re-allocate an array with a different size and copy the contents of the old array to the new array.Example:class ResizableArray { public static void main (String[] args) { int[] a = {1, 2, 3}; a = (int[])resizeArray(a, 5); a[3] = 4; a[4] = 5; for (int i=0; i 0) System.arraycopy(oldArray, 0, newArray, 0, preserveLength); return newArray; } } Output:1 2 3 4 5
To create Horizontal slider in Java, use the Swing JSlider. Let us first create a frame and a Horizontal slider in it −JFrame frame = new JFrame("Frame with Slider"); JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 70);Now, we will set the values for the slider. Display the ticks −slider.setMinorTickSpacing(5); slider.setMajorTickSpacing(20); slider.setPaintTicks(true); slider.setPaintLabels(true); Add the slider in the panel: JPanel panel = new JPanel(); panel.add(slider);The following is an example to create horizontal slider −Examplepackage my; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JSlider; import javax.swing.WindowConstants; public class SwingDemo { public static void main(String[] args) { JFrame frame = new ... Read More
The word order is a reserved order in MySQL and you have used it in the query. To get rid of the syntax error, you need to use backticks(` `) around the order.The correct syntax is as follows −select *from yourTableName ORDER BY `order` DESC;Let us first create a table −mysql> create table DemoTable ( `order` int ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(89); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values(67); Query OK, 1 row affected (0.13 sec) ... Read More
The content attribute of the element is used to set the meta information in an HTML document. This can be the information for the description or the keywords, for name attribute.Following is the syntax:Above, the text is the meta information.Let us now see an example to implement the content attribute of the element:Example Live Demo Tutorials Programming tutorials for free: Java C++ C C# OutputIn the above example, under the element, we have set the description: The description i.e. the meta information is set ... Read More
Pychecker and Pylint are the static analysis tools that help to find bugs in python.Pychecker is an opensource tool for static analysis that detects the bugs from source code and warns about the style and complexity of the bug.Pylint is highly configurable and it acts like special programs to control warnings and errors, it is an extensive configuration file Pylint is also an opensource tool for static code analysis it looks for programming errors and is used for coding standard. it checks the length of each programming line. it checks the variable names according to the project style. it can also be used as ... Read More
A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each case.Syntaxswitch(expression) { case value : // Statements break; case value : // Statements break; // You can have any number of case statements. default : // Statements }Rules to be followedWhile working with a switch statement keep the following points in mind −We must only use int, ... Read More
The HTML DOM Location replace() method is used for rendering a new document replacing the current document. It also removes the current document URL from document history disabling navigation to old document using ‘back’ button.SyntaxFollowing is the syntax −location.replace(URLString)ExampleLet us see an example for Location replace() property − Live Demo Location replace() form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP