The following is an example to print variable name.Example Live Demo#include #define VariableName(name) #name int main() { int name; char ch; printf("The variable name : %s", VariableName(name)); printf("The variable name : %s", VariableName(ch)); return 0; }OutputThe variable name : name The variable name : chIn the above program, the variable names are printed by defining the method before main()#define VariableName(name) #nameTwo variables of different datatypes are declared. By using the defined function, variable names are printed.int name; char ch; printf("The variable name : %s", VariableName(name)); printf("The variable name : %s", VariableName(ch));
Let us first declare a Double −Double ob = new Double(99.12);Use the toString() method to convert Double into String.String res = ob.toString();The following is the complete example.Example Live Demopublic class Demo { public static void main(String args[]) { Double ob = new Double(99.12); String res = ob.toString(); System.out.println(res); } }Output99.12
To compare two Java double arrays, use the Arrays.equals() method. The following are our double arrays.double[] arr1 = new double[] { 1.3, 7.2, 4.2 }; double[] arr2 = new double[] { 1.3, 7.2, 4.2 }; double[] arr3 = new double[] { 2.8, 5.3, 9.8 }; double[] arr4 = new double[] { 2.9, 5.8, 7.8 };Now, let us compare the above arrays. Two of these arrays will be compared at once.Arrays.equals(arr1, arr2); Arrays.equals(arr1, arr3); Arrays.equals(arr1, arr4);The following is the final example to compare Java double arrays.Example Live Demoimport java.util.*; public class Demo { public static void main(String args[]) { double[] arr1 = new double[] { 1.3, 7.2, 4.2 }; double[] arr2 = new double[] { 1.3, ... Read More
Variable sized arrays are data structures whose length is determined at runtime rather than compile time. These arrays are useful in simplifying numerical algorithm programming. The C99 is a C programming standard that allows variable sized arrays.A program that demonstrates variable sized arrays in C is given as follows −Example Live Demo#include int main(){ int n; printf("Enter the size of the array: "); scanf("%d", &n); int arr[n]; for(int i=0; i
The ternary operator is also known as the conditional operator. This operator consists of three operands and is used to evaluate Boolean expressions.Let’s say we have the following two double values.double val1 = 20.0; double val2 = 3.7;Now, let us use the ternary operator to check for the first value.System.out.println(val1 == 20 ? "Correct!" : "Incorrect!");If the above condition is correct i.e. val is equal to 20, therefore first statement “Correct” will be returned. If it isn’t equal, then the second statement will get evaluated.The following is the final example.Example Live Demoimport java.util.*; public class Demo { public static void main(String args[]) { double val1 = 20.0; ... Read More
Here we will see how we can get the UNIX shell style pattern matching techniques using Python. There is a module called fnmatch, which is used to do the work. This module is used to compare file name against a pattern, then returns True or False according to the matches.To use it at first we need to import it the fnmatch standard library module.import fnmatchIn the Unix terminal, there are some wildcards to match the patterns. These are like below −‘*’ The asterisk is used to match everything.‘?’ Question Mark is for matching a single character.[seq] Sequences are used to ... Read More
Here we will see how Python can be used to get the Round Trip Time (RTT). The RTT is the time which is taken by the entire trip of a signal. It means the time between the starting time when a signal is sent and the receiving time of the acknowledge signal.The RTT results varies on different parameters like.The data transfer rate of the sender’s side.The nature of the transmission media.The actual distance between the sender and receiver.The number of nodes between sender and receiver.The amount of traffic on LAN.Number of requests handled by intermediate points.Example Codeimport time import requests ... Read More
To convert double primitive type to a Double object, you need to use Double constructor.Let’s say the following is our double primitive.// double primitive double val = 23.78;To convert it to a Double object, use Double constructor.// Double object Double ob = new Double(val);Example Live Demopublic class Demo { public static void main(String args[]) { // double primitive double val = 23.78; // Double object Double ob = new Double(val); System.out.println(ob); } }Output23.78
The Double isInfinite() method returns true if this Double value is infinitely large in magnitude, false otherwise.Let’s say we have the following Double values.Double val1 = new Double(3/0.); Double val2 = new Double(0/0.);Use the isInfinite() method now. The return value is a boolean.val1.isInfinite(); val2.isInfinite();The following is the final example.Example Live Demopublic class Demo { public static void main(String args[]) { Double val1 = new Double(3/0.); Double val2 = new Double(0/0.); System.out.println(val1.isInfinite()); System.out.println(val2.isInfinite()); } }Outputtrue false
The java.lang.Double.isNan() method returns true if the specified number is a Not-a-Number (NaN) value, false otherwise.Let’s say the following are our Double values.Double val1 = new Double(3/0.); Double val2 = new Double(0/0.);Now, we will use the isNan() method to check whether the number is a NaN or not.val1.isNaN(); val2.isNaN()The following is our final example.Example Live Demopublic class Demo { public static void main(String args[]) { Double val1 = new Double(3/0.); Double val2 = new Double(0/0.); System.out.println(val1.isNaN()); System.out.println(val2.isNaN()); } }Outputfalse true