Karthikeya Boyini has Published 2383 Articles

Display two digits day number in Java

karthikeya Boyini

karthikeya Boyini

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

886 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

221 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

235 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

malloc() vs new() in C/C++

karthikeya Boyini

karthikeya Boyini

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

5K+ Views

malloc()The function malloc() is used to allocate the requested size of bytes and it returns a pointer to the first byte of allocated memory. It returns null pointer, if fails.Here is the syntax of malloc() in C++ language, pointer_name = (cast-type*) malloc(size);Here, pointer_name − Any name given to the pointer.cast-type ... Read More

What is the size of void pointer in C/C++?

karthikeya Boyini

karthikeya Boyini

Updated on 26-Jun-2020 07:42:28

7K+ Views

The size of void pointer varies system to system. If the system is 16-bit, size of void pointer is 2 bytes. If the system is 32-bit, size of void pointer is 4 bytes. If the system is 64-bit, size of void pointer is 8 bytes.Here is an example to find ... Read More

isgreater() in C/C++

karthikeya Boyini

karthikeya Boyini

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

210 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

200 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

569 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 alphabetic uppercase

karthikeya Boyini

karthikeya Boyini

Updated on 26-Jun-2020 07:22:15

55 Views

To check whether the entered value is ASCII 7-bit alphabetic uppercase, check the character from ‘A’ to ‘Z’.Here, we have a character.char one = 'T';Now, we have checked a condition with if-else to check for uppercase character from ‘A’ to ‘Z’if (one >= 'A' && one = 'A' && one ... Read More

Advertisements