Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles on Trending Technologies
Technical articles with clear explanations and examples
Check if Hashtable has a fixed size in C#
To check if Hashtable has a fixed size, the code is as follows −Exampleusing System; using System.Collections; public class Demo { public static void Main(){ Hashtable hash = new Hashtable(10); hash.Add("1", "A"); hash.Add("2", "B"); hash.Add("3", "C"); hash.Add("4", "D"); hash.Add("5", "E"); hash.Add("6", "F"); hash.Add("7", "G"); hash.Add("8", "H"); hash.Add("9", "I"); hash.Add("10", "J"); Console.WriteLine("Is the Hashtable having fixed size? = "+hash.IsFixedSize); } }OutputThis will produce ...
Read MoreFind if a molecule can be formed from 3 atoms using their valence numbers in C++
As we know the valance number is the number that defines how-many bonds the atom must form with other atoms. We have the valance numbers of three atoms. We have to check whether they can make one molecule or not. Atoms can form multiple bonds with each other. So if the valance numbers are 2, 4, 2, then the output will be YES. As the bonds are like below −1 – 2, 1 – 2, 2 – 3, 2 – 3.Suppose the valance numbers are a, b and c. Consider c is largest. Then we have two cases in which ...
Read MoreGMT Time in Perl
The function gmtime() in Perl works just like localtime() function but the returned values are localized for the standard Greenwich time zone. When called in list context, $isdst, the last value returned by gmtime, is always 0. There is no Daylight Saving Time in GMT.You should make a note on the fact that localtime() will return the current local time on the machine that runs the script and gmtime() will return the universal Greenwich Mean Time, or GMT (or UTC).Try the following example to print the current date and time but on GMT scale −Example#!/usr/local/bin/perl $datestring = gmtime(); print "GMT ...
Read MoreCheck if the Hashtable contains a specific value in C#
To check if the Hashtable contains a specific value, the code is as follows −Exampleusing System; using System.Collections; public class Demo { public static void Main(){ Hashtable hash = new Hashtable(); hash.Add("1", "A"); hash.Add("2", "B"); hash.Add("3", "C"); hash.Add("4", "D"); hash.Add("5", "E"); hash.Add("6", "F"); hash.Add("7", "G"); hash.Add("8", "H"); hash.Add("9", "I"); hash.Add("10", "J"); Console.WriteLine("Hashtable Key and Value pairs..."); foreach(DictionaryEntry entry in hash){ ...
Read MoreGetting the list of keys of a SortedList object in C#
To get the list of keys of a SortedList object, the code is as follows −Exampleusing System; using System.Collections; public class Demo { public static void Main(String[] args) { SortedList list1 = new SortedList(); list1.Add("One", 1); list1.Add("Two ", 2); list1.Add("Three ", 3); list1.Add("Four", 4); list1.Add("Five", 5); list1.Add("Six", 6); list1.Add("Seven ", 7); list1.Add("Eight ", 8); list1.Add("Nine", 9); list1.Add("Ten", 10); Console.WriteLine("SortedList1 elements..."); ...
Read MoreFormat Date and Time in Perl
You can use localtime() function in Perl to get a list of 9-elements and later you can use the printf() function to format date and time based on your requirements as follows −Example#!/usr/local/bin/perl ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); printf("Time Format - HH:MM:SS"); printf("%02d:%02d:%02d", $hour, $min, $sec);OutputWhen the above code is executed, it produces the following result −Time Format - HH:MM:SS 06:58:52
Read MoreCheck if a SortedSet object is a proper subset of the specified collection in C#
To check if a SortedSet object is a proper subset of the specified collection, the code is as follows −Exampleusing System; using System.Collections.Generic; public class Demo { public static void Main(){ SortedSet set1 = new SortedSet(); set1.Add(20); set1.Add(40); set1.Add(60); set1.Add(80); set1.Add(100); set1.Add(120); set1.Add(140); Console.WriteLine("Elements in SortedSet1..."); foreach (int res in set1){ Console.WriteLine(res); } SortedSet set2 = new SortedSet(); ...
Read MoreGetting the list of Values of a SortedList object in C#
To get the list of values of a SortedList object, the code is as follows −Exampleusing System; using System.Collections; public class Demo { public static void Main(String[] args) { SortedList list = new SortedList(); list.Add("A", 1); list.Add("B ", 2); list.Add("C ", 3); list.Add("D", 4); list.Add("E", 5); list.Add("F", 6); list.Add("G", 7); list.Add("H", 8); Console.WriteLine("SortedList elements..."); foreach(DictionaryEntry d in list) { Console.WriteLine(d.Key + " ...
Read MoreFind k’th character of decrypted string in C++
Suppose we have one encoded string, where repetitions of substrings are represented as substring followed by count of substrings. So if the string is like ab2cd2, it indicates ababcdcd, and if k = 4, then it will return kth character, that is b here.To solve this, we initially take empty decrypted string then decompress the string by reading substring and its frequency one by one. Then append current substring in the decrypted string by its frequency. We will repeat this process till the string has exhausted, and print the Kth character from decrypted string.Example#include using namespace std; char findKthCharacter(string str, ...
Read MoreEpoch time in Perl
You can use the time() function in Perl to get epoch time, i.e., the numbers of seconds that have elapsed since a given date, in Unix is January 1, 1970.Example#!/usr/local/bin/perl $epoc = time(); print "Number of seconds since Jan 1, 1970 - $epoc";OutputWhen the above code is executed, it produces the following result −Number of seconds since Jan 1, 1970 - 1361022130You can convert a given number of seconds into date and time string as follows −Example#!/usr/local/bin/perl $datestring = localtime(); print "Current date and time $datestring"; $epoc = time(); $epoc = $epoc - 24 * 60 * 60; # ...
Read More