Karthikeya Boyini has Published 2383 Articles

How to output colored text to a Linux terminal?

karthikeya Boyini

karthikeya Boyini

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

8K+ Views

Here we will see how to print some lines into the linux terminal with some color. Here we are doing anything special into C++ code. We are just using some linux terminal commands to do this. The command for this kind of output is like below.\033[1;31m Sample Text \033[0mThere are ... Read More

Determine what a MySQL DB’s charset is set to

karthikeya Boyini

karthikeya Boyini

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

90 Views

Let’s say we are creating a database “web” −mysql> SHOW CREATE DATABASE web;This will produce the following output displaying the default charset as well −+----------+-----------------------------------------------------------------------------------------+ | Database | Create Database                                         ... Read More

Averaging a total from a Score column in MySQL with the count of distinct ids?

karthikeya Boyini

karthikeya Boyini

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

53 Views

You can use DISTINCT along with COUNT(). Let us first create a table −mysql> create table DemoTable    -> (    -> Id int,    -> Score int    -> ); Query OK, 0 rows affected (0.95 sec)Insert some records in the table using insert command −mysql> insert into DemoTable ... Read More

How can I clear console using C++?

karthikeya Boyini

karthikeya Boyini

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

11K+ Views

We can clear the console using C++ code. To do this we have to execute some system commands. In Linux systems, the POSIX is used. We can call system() function to execute system command. For clearing the console in linux, we can use “clear” command. This will be passed inside ... Read More

How to create a high resolution timer with C++ and Linux?

karthikeya Boyini

karthikeya Boyini

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

2K+ Views

To create high resolution timer we can use the chrono library. This library has high resolution clock. This can count in nanoseconds.In this program we will see the execution time in nanoseconds. We will take the time value at first, then another time value at the last, then find the ... Read More

Bool to int conversion in C++

karthikeya Boyini

karthikeya Boyini

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

10K+ Views

Here we will see how to convert bool to int equivalent in C++. Bool is a datatype in C++, and we can use true or false keyword for it. If we want to convert bool to int, we can use typecasting. Always true value will be 1, and false value ... Read More

How to change JLabel font in Java

karthikeya Boyini

karthikeya Boyini

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

11K+ Views

To change JLabel font, use the setFont() method −JLabel lable = label.setFont(new Font("Verdana", Font.PLAIN, 18));Examplepackage my; import java.awt.Font; import javax.swing.*; public class SwingDemo {    public static void main(String args[]) {       JFrame frame = new JFrame("Label Example");       JLabel label;       label = ... Read More

Difference between “int main()” and “int main(void)” in C/C++?

karthikeya Boyini

karthikeya Boyini

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

3K+ Views

Sometimes we see that there are two types of main function definition. The int main() and int main(void). So is there any difference?In C++, there is no difference. In C also both are correct. But the second one is technically better. It specifies that the function is not taking any ... Read More

How to change text font for JLabel with HTML in Java?

karthikeya Boyini

karthikeya Boyini

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

726 Views

To change text font, you can use the setFont() method of JLabel −label.setFont(new Font("Verdana", Font.PLAIN, 12));The following is an example to change text font for JLabel with HTML −Exampleimport java.awt.Font; import javax.swing.*; public class SwingDemo {    public static void main(String args[]) {       JFrame frame = new ... Read More

Java Program to set alignment for text in JLabel

karthikeya Boyini

karthikeya Boyini

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

6K+ Views

JLabel Left AlignedThe following is an example to set left alignment for JLabel −Exampleimport java.awt.Font; import javax.swing.*; public class SwingDemo {    public static void main(String args[]) {       JFrame frame = new JFrame("Label Demo");       JLabel label;       label = new JLabel("Left aligned!", ... Read More

Advertisements