Karthikeya Boyini has Published 2193 Articles

Factorial of Large Number Using boost multiprecision Library

karthikeya Boyini

karthikeya Boyini

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

162 Views

To find the factorial of a large number, we can use the boost library. This library provides high precision numbers. Using boost multiprecision library we can get more precision than 64 bits.Example#include #include using boost::multiprecision::cpp_int; using namespace std; cpp_int Large_Fact(int number) {    cpp_int fact = 1;   ... Read More

Rule Of Three in C++

karthikeya Boyini

karthikeya Boyini

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

335 Views

The Rule of three is a rule of thumb when using C++. This is kind of a good practice rule that says that If your class needs any ofa copy constructor, an assignment operator, or a destructor, defined explicitly, then it is likely to need all three of them.Why is ... Read More

What is the size of int, long type as per C++ standard?

karthikeya Boyini

karthikeya Boyini

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

598 Views

Here we will see what are the sizes of the int and long type data in C++. The sizes are depending on the system architecture and the Operating system.So in the 32-bit system, the standard is ILP32. In this standard the int, long and the pointer variables are of 32-bits.For ... Read More

How to automatically generate a stacktrace when a gcc C++ program crashes?

karthikeya Boyini

karthikeya Boyini

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

2K+ Views

For Linux and we can use gcc to compile C/C++ codes. This compiler uses glibc library. We can use the backtrace() function to trace the error. This function is present inside the execinfo.h header file. In this example, we are going to display Segmentation fault error using the stack trace ... Read More

Java Program to display the contents in JTextArea

karthikeya Boyini

karthikeya Boyini

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

435 Views

The following is an example to display the contents of a text file in JTextArea −Exampleimport java.awt.*; import java.awt.event.*; import javax.swing.*; public class SwingDemo {    private JFrame mainFrame;    private JLabel statusLabel;    private JPanel controlPanel;    public SwingDemo() {       prepareGUI();    }    public static ... Read More

What is the difference between static_cast<> and C style casting?

karthikeya Boyini

karthikeya Boyini

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

4K+ Views

Here we will see what are the differences between static_cast and normal C style cast.The normal cast like (int)x is C style typecasting where static_cast(x) is used in C++.This static_cast() gives compile time checking facility, but the C style casting does not support that. This static_cast() can be spotted anywhere ... Read More

How to activate and deactivate JFrame in Java

karthikeya Boyini

karthikeya Boyini

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

561 Views

Here, we are activating a frame. For deactivation, we have used dispose −Thread.sleep(2000); frame.setVisible(false);The frame first activates and then deactivates after 2 seconds since we have set sleep to 2000 miliseconds.The following is an example to activate and deactivate JFrame −Exampleimport java.awt.Frame; import javax.swing.JFrame; import javax.swing.JLabel; public class SwingDemo { ... Read More

How to print Unicode character in C++?

karthikeya Boyini

karthikeya Boyini

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

6K+ Views

To print the Unicode characters, the process is very similar to the actual printing process in C++.We can put the Unicode value with the prefix \u. Thus we can successfully print the Unicode character.Note: If the console does not support Unicode, then you cannot get the correct result. Here we ... Read More

Java Program to create JRadioButton from text

karthikeya Boyini

karthikeya Boyini

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

134 Views

The following is an example to create JRadioButton from text −Examplepackage my; import java.awt.FlowLayout; import java.awt.event.KeyEvent; import javax.swing.ButtonGroup; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JRadioButton; public class SwingDemo {    public static void main(String[] args) {       JRadioButton radio1 = new JRadioButton("Cricket");       JRadioButton radio2 = new ... Read More

How can we clear all selections in Java Swing JList?

karthikeya Boyini

karthikeya Boyini

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

677 Views

To clear all selections, use the List clearSelection() method in Java −JList list = new JList(sports); list.clearSelection();Above, the elements in Sports array is a String array −String sports[]= { "Cricket", "Football", "Hockey", "Rugby"};The following is an example to clear all selection in JList −Examplepackage my; import java.awt.event.*; import java.awt.*; import ... Read More

Advertisements