Samual Sam has Published 2310 Articles

Parameter Passing Techniques in C/C++

Samual Sam

Samual Sam

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

6K+ Views

In C we can pass parameters in two different ways. These are call by value, and call by address, In C++, we can get another technique. This is called Call by reference. Let us see the effect of these, and how they work.First we will see call by value. In ... Read More

How to disable a JLabel in Java?

Samual Sam

Samual Sam

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

519 Views

To disable a JLabel, use the setEnabled() method −JLabel label; label.setEnabled(false);The following is an example to disable a JLabel −package my; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import javax.swing.*; import javax.swing.border.Border; public class SwingDemo {    public static void main(String args[]) {       JFrame frame = new JFrame("Demo"); ... Read More

How will you show memory representation of C variables?

Samual Sam

Samual Sam

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

549 Views

Here we will see how to print the memory representation of C variables. Here we will show integers, floats, and pointers.To solve this problem, we have to follow these steps −Get the address and the size of the variableTypecast the address to the character pointer to get byte addressNow loop ... Read More

How to change JFrame background color in Java

Samual Sam

Samual Sam

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

23K+ Views

At first, create a JFrame −JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setPreferredSize(new Dimension(550, 300));Now, change the background color of the JFrame −frame.getContentPane().setBackground(Color.BLUE);The following is an example to change JFrame background color −Exampleimport java.awt.Color; import java.awt.Dimension; import javax.swing.JFrame; public class SwingDemo {    public static void main(String[] args) {     ... Read More

How to close JFrame on the click of a Button in Java

Samual Sam

Samual Sam

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

13K+ Views

Set frame.dispose() on the click of a button to close JFrame. At first create a button and frame −JFrame frame = new JFrame(); JButton button = new JButton("Click to Close!");Now, close the JFrame on the click of the above button with Action Listener −button.addActionListener(e -> {    frame.dispose(); });The following ... Read More

How to count set bits in a floating point number in C?

Samual Sam

Samual Sam

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

527 Views

In this problem, one floating point value is given. We have to find number of set bits in the binary representation of it.For example, if a floating point number is 0.15625, so there are six set bits. A typical C compiler used single precision floating point representation. So it will ... Read More

How to write a running C code without main()?

Samual Sam

Samual Sam

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

8K+ Views

Here we will see, one program can be written without main or not? The answer is yes. We can write program, that has no main() function.In many places, we have seen that the main() is the entry point of a program execution. Just from the programmers perspective this is true. ... Read More

Use of bool in C

Samual Sam

Samual Sam

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

2K+ Views

In C there is no predefined datatype as bool. We can create bool using enum. One enum will be created as bool, then put the false, and true as the element of the enum. The false will be at the first position, so it will hold 0, and true will ... Read More

C++ Program to Implement the Alexander Bogomolny’s UnOrdered Permutation Algorithm for Elements From 1 to N

Samual Sam

Samual Sam

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

131 Views

This is a C++ program to implement the Alexander Bogomolny’s UnOrdered Permutation Algorithm for elements from 1 to NAlgorithmsBegin    function AlexanderBogomolny() to implement the Algorithms    Arguments:       Val[] = an array       N = number of elements taken as input.       K ... Read More

How to set default date time as system date time in MySQL?

Samual Sam

Samual Sam

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

544 Views

You can use CURRENT_TIMESTAMP to set system date time. Let us first create a table −mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    ClientFirstName varchar(20),    ClientLastName varchar(20),    ClientAge int ); Query OK, 0 rows affected (0.66 sec)Following is the query to set default ... Read More

Advertisements