Samual Sam has Published 2492 Articles

Deque in Python

Samual Sam

Samual Sam

Updated on 26-Jun-2020 09:08:39

6K+ Views

The Deque is basically a generalization of stack and queue structure, where it is initialized from left to right. It uses the list object to create a deque.It provides O(1) time complexity for popping and appending.The Dequeis a standard library class, which is located in the collections module.To use it ... Read More

What is the proper declaration of main in C++?

Samual Sam

Samual Sam

Updated on 26-Jun-2020 09:05:26

89 Views

The main() function is a global function. It is used to start the execution of program. Every program should have main(). The command line arguments argc and argv are optional.The standard prototype of main() function is as follows.int main() { body } OR int main(int argc, char *argv[]) { body ... Read More

Format double type in Java

Samual Sam

Samual Sam

Updated on 26-Jun-2020 09:05:22

2K+ Views

Let’s say we have the following three values −double val1 = 15.546; double val2 = 25.87; double val3 = Math.PI;Let us now format these double-type numbers. Firstly, we are formatting Euler’s number with Math.exp(). After that, we have also evaluated log. The %.3f you can see here is what we ... Read More

C++ Program to Find Fibonacci Numbers using Iteration

Samual Sam

Samual Sam

Updated on 26-Jun-2020 09:04:47

6K+ Views

The following is an example to find fibonacci series using iteration.Example Live Demo#include using namespace std; void fib(int num) {    int x = 0, y = 1, z = 0;    for (int i = 0; i < num; i++) {       cout

Java Program to convert Double to numeric primitive data types

Samual Sam

Samual Sam

Updated on 26-Jun-2020 09:03:00

1K+ Views

Let’s say we have Double object here.Double obj = new Double("39.45");Now, if we want to convert this Double to short primitive data type. For that, use the in-built shortValue() method.// converting to short primitive types short shortObj = obj.shortValue(); System.out.println(shortObj);In the same way convert Double to another numeric primitive data ... Read More

Write a power (pow) function using C++

Samual Sam

Samual Sam

Updated on 26-Jun-2020 09:02:50

1K+ Views

The power function is used to find the power given two numbers that are the base and exponent. The result is the base raised to the power of the exponent.An example that demonstrates this is as follows −Base = 2 Exponent = 5 2^5 = 32 Hence, 2 ... Read More

Java Program to convert Double into String using toString() method of Double class

Samual Sam

Samual Sam

Updated on 26-Jun-2020 09:00:12

79 Views

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.12Read More

Initialization of a multidimensional array in C

Samual Sam

Samual Sam

Updated on 26-Jun-2020 08:59:47

328 Views

Array is a collection of same type of elements at contiguous memory location. The lowest address corresponds to the first element while highest corresponds to last element. Array index starts with zero(0) and ends with the size of array minus one(array size - 1). Array size must be integer greater ... Read More

Apply Ternary operator on double value in Java

Samual Sam

Samual Sam

Updated on 26-Jun-2020 08:58:33

339 Views

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 ... Read More

Unix filename pattern matching in Python

Samual Sam

Samual Sam

Updated on 26-Jun-2020 08:57:31

1K+ Views

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 ... Read More

Advertisements