karthikeya Boyini

karthikeya Boyini

1,421 Articles Published

Articles by karthikeya Boyini

Page 117 of 143

1’s and 2’s complement of a Binary Number?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 5K+ Views

Binary Number is expressed in base 2. It uses only two digits ‘0’ and ‘1’. Each digit in a binary number is a bit.Sample binary Number − 01000101111’s ComplementOne's complement of a binary number is obtained by reversing the digits of the binary number i.e. transforming 1 with 0 and 0 with 1.Example1’s Complement of 101100 = 0100112’s ComplementTwo’s complement of a binary number is obtained by adding one to the one’s complement of a binary number i.e. 1’s complement + 1.Example2’s complement of 101101 is 010011.Example CodeCode to find One’s and two’s complement −#include #include using namespace std; ...

Read More

C++ Program to Generate All Possible Combinations of a Given List of Numbers

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 2K+ Views

This is a C++ program to generate all possible combinations of a given list of numbersAlgorithmsBegin    Take the number of elements and the elements as input.    function Combi(char a[], int reqLen, int s, int currLen, bool check[], int l) :    If currLen>reqLen then    Return    Else if currLen=reqLen then       Then print the new generated sequence.    If s=l then       Then return no further element is left.    For every index there are two option:    either proceed with a start as ‘true’ and recursively call Combi() with incremented value of ...

Read More

Python Rational numbers (fractions)

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 2K+ Views

Any number which can be expressed as a quotient or fraction in the form of p/q is called a rational number. The fractions module of Python library provides functionality for rational number arithmetic.This module defines a Fraction class. Its object can be constituted in various ways as below −Fraction(num, denom)The first version of Fraction constructor receives two parameters for numerator and denominator. Default numerator is 0 and default denominator is 1. Value of denominator = 0 throws ZeroDivisionError.>>> from fractions import Fraction >>> n1 = Fraction(2, 5) >>> n1 Fraction(2, 5) >>> n2 = Fraction(6, 15) >>> n2 Fraction(2, 5) ...

Read More

Display 3 decimal places in MySQL?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 2K+ Views

To display 3 digits after decimal, use TRUNCATE(). Let us first create a table −mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Value DECIMAL(10, 5) ); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Value) values(109.4567); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable(Value) values(15.9875); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable(Value) values(1234.2346789); Query OK, 1 row affected, 1 warning (0.14 sec)Following is the query to display all records from the table using select statement −mysql> select ...

Read More

I need to understand how to use a bean and update its properties in JSP page. Please share an example.

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 757 Views

The useBean action is quite versatile. It first searches for an existing object utilizing the id and scope variables. If an object is not found, it then tries to create the specified object.The simplest way to load a bean is as follows −Once a bean class is loaded, you can use jsp:setProperty and jsp:getProperty actions to modify and retrieve the bean properties.Following table lists out the attributes associated with the useBean action −S.No.Attribute & Description1classDesignates the full package name of the bean.2typeSpecifies the type of the variable that will refer to the object.3beanNameGives the name of the bean as specified ...

Read More

How to select the table with the greatest number of columns in MySQL?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 159 Views

You can use INFORMATION_SCHEMA.COLUMNS to get the table with the greatest number of columns. The syntax is as follows −SELECT TABLE_NAME, COUNT(*) AS anyAliasName FROM INFORMATION_SCHEMA.COLUMNS GROUP BY TABLE_NAME ORDER BY yourAliasName DESC LIMIT 1;Following is the query to select the table that has the greatest number of columns. We are getting this result because we have set the count to DESC and used GROUP BY TABLE_NAME −mysql> SELECT TABLE_NAME, COUNT(*) as TOTAL_COUNT FROM INFORMATION_SCHEMA.COLUMNS GROUP BY TABLE_NAME ORDER BY TOTAL_COUNT DESC LIMIT 1;This will produce the following output −+-----------------------------------+-------------+ | TABLE_NAME                   ...

Read More

JavaTuples setAt0() method for Septet class

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 127 Views

The setAt0() method is used to set the Septet value in JavaTuples and a copy with new value at the specified index i.e. index 0 here.Let us first see what we need to work with JavaTuples. To work with Septet class in JavaTuples, you need to import the following package −import org.javatuples.Septet;Note − Steps to download and run JavaTuples program. If you are using Eclipse IDE to run Septet Class in JavaTuples, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file.The following is an example −Exampleimport org.javatuples.Septet; import ...

Read More

What is the use of jsp text action element?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 200 Views

The action can be used to write the template text in JSP pages and documents. Following is the simple syntax for this action −Template dataThe body of the template cannot contain other elements; it can only contain text and EL expressions (Note − EL expressions are explained in a subsequent chapter). Note that in XML files, you cannot use expressions such as ${whatever > 0}, because the greater than signs are illegal. Instead, use the gt form, such as ${whatever gt 0} or an alternative is to embed the value in a CDATA section.]]>If you need to include a ...

Read More

How to insert into two tables using a single MySQL query?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 6K+ Views

You can use stored procedure to insert into two tables in a single query. Let us first create a table −mysql> create table DemoTable (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentFirstName varchar(20) ); Query OK, 0 rows affected (0.56 sec)Here is the query to create second table −mysql> create table DemoTable2 (    ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    ClientName varchar(20),    ClientAge int ); Query OK, 0 rows affected (0.76 sec)Following is the query to create stored procedure to insert into two tables created above −mysql> DELIMITER //    mysql> CREATE PROCEDURE insert_into_twoTables(name ...

Read More

How to calculate the possibilities of duplication for random number within a range in Java

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 212 Views

To get the duplicate numbers for random numbers in a range, loop through and create two Random class objects −Use nextInt() to get the next number −intrandVal1 = new Random().nextInt(50); intrandVal2 = new Random().nextInt(50);Now, compare both the above numbers −if (randVal1 == randVal2) {    System.out.println("Duplicate number = "+randVal1); }All the above is to be done in a loop −for (int i = 1; i

Read More
Showing 1161–1170 of 1,421 articles
« Prev 1 115 116 117 118 119 143 Next »
Advertisements