Karthikeya Boyini has Published 2193 Articles

Display two digits day number in Java

karthikeya Boyini

karthikeya Boyini

Updated on 26-Jun-2020 07:54:11

1K+ Views

To display two-digit day number, use the SimpleDateFormat('dd') as shown below −// displaying two-digit day number f = new SimpleDateFormat("dd"); String strDay = f.format(new Date()); System.out.println("Day Number = "+strDay);Since, we have used the Format and SimpleDateFormat class above, therefore import the following packages. With that, we have also used the ... Read More

strcspn() in C

karthikeya Boyini

karthikeya Boyini

Updated on 26-Jun-2020 07:52:51

347 Views

The function strcspn() counts the number of characters before first match of characters in both strings. This is declared in “string.h” header file. It returns the number of characters of first string before the occurrence of first matched character.Here is the syntax of strcspn() in C language, size_t strcspn(const char ... Read More

strxfrm() in C/C++

karthikeya Boyini

karthikeya Boyini

Updated on 26-Jun-2020 07:51:52

354 Views

The function strxfrm() transforms the source string to the current locale and copies the first number of characters of transformed string to the destination. It is declared in “locale.h” header file in C language.Here is the syntax of strxfrm() in C language, size_t strxfrm(char *destination, const char *source, size_t number)Here, ... Read More

What should main() return in C/C++?

karthikeya Boyini

karthikeya Boyini

Updated on 26-Jun-2020 07:46:45

5K+ Views

The return value of main() function shows how the program exited. The normal exit of program is represented by zero return value. If the code has errors, fault etc., it will be terminated by non-zero value.In C++ language, the main() function can be left without return value. By default, it ... Read More

isgreater() in C/C++

karthikeya Boyini

karthikeya Boyini

Updated on 26-Jun-2020 07:35:55

322 Views

The function isgreater() is used to check that the first argument is greater than the second one or not. It is declared in “math.h” header file in C language. It returns true, if successful, otherwise false.Here is the syntax of isgreater().bool isgreater(value1 , value2);Here, value1 − This is the first ... Read More

Convert from String to long in Java

karthikeya Boyini

karthikeya Boyini

Updated on 26-Jun-2020 07:29:06

303 Views

To convert String to long, the following are the two methods.Method 1The following is an example wherein we use parseLong() method.Example Live Demopublic class Demo {    public static void main(String[] args) {       String myStr = "5";       Long myLong = Long.parseLong(myStr);       System.out.println("Long: ... Read More

Convert octal number to decimal number in Java

karthikeya Boyini

karthikeya Boyini

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

722 Views

To convert octal to decimal number, use the Integer.parseInt() method with radix 8. Here, the radix is for Octal i.e. 8.Let’s say we have the following octal string.String myOctal = "25";To convert it to decimal, use the Integer.parseInt() method.int val = Integer.parseInt(myOctal, 8);The following is the complete example.Example Live Demopublic class ... Read More

Java Program to check whether the entered value is ASCII 7-bit control character

karthikeya Boyini

karthikeya Boyini

Updated on 26-Jun-2020 07:13:37

294 Views

To check whether the entered value is ASCII 7-bit control character, check the characters ASCII value before 32 and 127. These are the control characters.Here, we have a character.char one = ' n ';Now, we have checked a condition with if-else to check for character less than 32 (ASCII) and ... Read More

Permutation and Combination in Java

karthikeya Boyini

karthikeya Boyini

Updated on 26-Jun-2020 07:04:26

6K+ Views

Permutation and Combination are a part of Combinatorics. Permutation is the different arrangements that a set of elements can make if the elements are taken one at a time, some at a time or all at a time. Combination is is the different ways of selecting elements if the elements ... Read More

Compare two objects of Character type in Java

karthikeya Boyini

karthikeya Boyini

Updated on 26-Jun-2020 06:59:37

764 Views

To compare two objects of Character type in Java, use the compareTo() method.Firstly, we have created two Character type.Character one = new Character('m'); Character two = new Character('k');Now, to compare them, we have used the compareTo() method.int res = one.compareTo(two);The following is the example that compares character objects.Example Live Demopublic class ... Read More

Advertisements