Print the given pattern recursively

Sunidhi Bansal
Updated on 30-Jul-2019 22:30:26

4K+ Views

Here, as per the given problem pattern needs to be displayed using recursive approach.Recursive function is the one that calls itself n number of times. There can be ‘n’ number of recursive function in a program. The problem working with recursive function is their complexity.AlgorithmSTART Step 1 -> function int printpattern(int n)    If n>0       Printpattern(n-1)       Print *    End IF End Step 2 -> function int pattern(int n)    If n>0       pattern(n-1)    End IF    Printpattern(n)    Print End STOPExample#include int printpattern(int n) {    if(n>0) { ... Read More

How to check if input is numeric in C++?

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

4K+ Views

Here we will see how to check whether a given input is numeric string or a normal string. The numeric string will hold all characters that are in range 0 – 9. The solution is very simple, we will simply go through each characters one by one, and check whether it is numeric or not. If it is numeric, then point to the next, otherwise return false value.Example#include using namespace std; bool isNumeric(string str) {    for (int i = 0; i < str.length(); i++)       if (isdigit(str[i]) == false)          return false; //when ... Read More

Handle JCheckBox Events with an ItemListener in Java

Krantik Chavan
Updated on 30-Jul-2019 22:30:26

1K+ Views

Here, we have used ItemListener to handle JCheckBox events i.e. whenever any of the CheckBox is selected.For example; When any of the sports like Football CheckBox is checked, event is fired and a message is visible in the botton.The following is an example to handle JCheckBox events with an ItemListener:Exampleimport java.awt.*; import java.awt.event.*; import javax.swing.*; public class SwingDemo {    private JFrame mainFrame;    private JLabel headerLabel;    private JLabel statusLabel;    private JPanel controlPanel;    public SwingDemo(){       prepareGUI();    }    public static void main(String[] args){       SwingDemo swingControlDemo = new SwingDemo();     ... Read More

Java DatabaseMetaData supportsTransactionIsolationLevel() method with example

Arushi
Updated on 30-Jul-2019 22:30:26

82 Views

JDBC provides support 5 transaction isolation levels through Connection interface.TRANSACTION_NONE: It is represented by integer value 0 does not support transactions.TRANSACTION_READ_COMMITTED: It is represented by integer value 2 supports transactions allowing Non-Repeatable Reads and, Phantom Reads.TRANSACTION_READ_UNCOMMITTED: It is represented by integer value 1 supports transactions allowing Dirty Reads, Non-Repeatable Reads and, Phantom Reads.TRANSACTION_REPEATABLE_READ: It is represented by integer value 4 supports transactions allowing only Phantom Reads.TRANSACTION_SERIALIZABLE: It is represented by integer value 8 supports transactions with out allowing Dirty Reads, Non-Repeatable Reads and, Phantom Reads.The supportsTransactionIsolationLevel() method of the DatabaseMetaData interface is used to determine whether the underlying database supports ... Read More

How to set the alignment of the JLabel content along the X axis on the left in Java

Smita Kapse
Updated on 30-Jul-2019 22:30:26

92 Views

To set the alignment of the label content along the X axis on the left, use the setHorizontalAlignment() method and set the location. Let us first set a label component. We have set the label background color as well so that we can check the alignment of the label’s content properly −JLabel label = new JLabel("Country "); label.setPreferredSize(new Dimension(190, 100)); label.setOpaque(true); label.setBackground(Color.BLUE); label.setForeground(Color.WHITE);Now, we will align the label content along the X axis on the left by seeting location as LEFT −label.setHorizontalAlignment(JLabel.LEFT);The following is an example to set the alignment of the JLabel content along the X axis on the ... Read More

How to find string count of a particular id in a column using a MySQL query?

Arjun Thakur
Updated on 30-Jul-2019 22:30:26

103 Views

For this, use the CHAR_LENGTH() function in MySQL. Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Subject longtext    ); Query OK, 0 rows affected (1.17 sec)Now you can insert some records in the table using insert command −mysql> insert into DemoTable(Subject) values('MySQL, MongoDB'); Query OK,  1 row affected (0.20 sec) mysql> insert into DemoTable(Subject) values('MySQL, MongoDB'); Query OK,  1 row affected (0.17 sec) mysql> insert into DemoTable(Subject) values('MongoDB'); Query OK,  1 row affected (0.13 sec) mysql> insert into DemoTable(Subject) values('MySQL'); Query OK,  1 row affected (0.15 sec) Display all records from the table using select statement : mysql> select *from DemoTable;Output+----+---------------+ | Id | Subject | +----+---------------+ | 1 | MySQL, MongoDB | | 2 | MySQL, MongoDB | | ... Read More

HTML DOM Abbreviation Object

Ankith Reddy
Updated on 30-Jul-2019 22:30:26

155 Views

The element is used in HTML to display abbreviations. The Abbreviation object represent this element.In the below example, we will learn how to access an abbreviation object −Example Live Demo Demo Heading BCCI Display the abbreviation title Abbreviation Title    function display() {       var a = document.getElementById("myid").title;       document.getElementById("demo").innerHTML = a;    } OutputClick on the button to display the title −

What is a ClassCastException and when it will be thrown in Java?\

raja
Updated on 30-Jul-2019 22:30:26

1K+ Views

The java.lang.ClassCastException is one of the unchecked exception in Java. It can occur in our program when we tried to convert an object of one class type into an object of another class type.When will be ClassCastException is thrownWhen we try to cast an object of Parent class to its Child class type, this exception will be thrown.When we try to cast an object of one class into another class type that has not extended the other class or they don't have any relationship between them.ExampleLive Democlass ParentTest {    String parentName;    ParentTest(String n1){       parentName = n1;    }    public ... Read More

HTML DOM Input Month disabled Property

Sharon Christine
Updated on 30-Jul-2019 22:30:26

57 Views

The HTML DOM input month disabled property returns and modify whether the input field of type=”month” in a HTML document is disabled or not.SyntaxFollowing is the syntax −1. Returning disabledobject.disabled2. Modifying disabledobject.disabled = true | falseExampleLet us see an example of HTML DOM input month defaultValue property − Live Demo    html{       height:100%;    }    body{       text-align:center;       color:#fff;       background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%)       center/cover no-repeat;       height:100%;    }    p{       font-weight:700;       font-size:1.2rem; ... Read More

Absolute Difference of even and odd indexed elements in an Array (C++)?

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

442 Views

Here we will see how we can get the absolute differences of odd and even indexed elements in an array. The absolute difference indicates that if the difference of one pair is negative, the absolute value will be taken. For an example, let the numbers are {1, 2, 3, 4, 5, 6, 7, 8, 9}. So the even position elements are 1, 3, 5, 7, 9 (starting from 0), and odd place elements are 2, 4, 6, 8. So the difference for even placed data are |1 - 3| = 2, then |2 - 5| = 3, |3 - 7| ... Read More

Advertisements