Samual Sam has Published 2492 Articles

Java Program to convert string value to float using Float.valueOf()

Samual Sam

Samual Sam

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

91 Views

The Float.valueOf() method is used in Java to convert string to float.The following are our string values.String str1 = "100.5"; String str2 = "200.5";To convert the string value to float, try the method valueOf()float val1 = (Float.valueOf(str1)).floatValue(); float val2 = (Float.valueOf(str2)).floatValue();The following is the complete example with output.Example Live Demopublic class ... Read More

C++ Program to Sum the digits of a given number

Samual Sam

Samual Sam

Updated on 26-Jun-2020 08:12:52

11K+ Views

Here is an example to calculate the sum of digits in C++ language,Example Live Demo#include using namespace std; int main() {    int x, s = 0;    cout > x;    while (x != 0) {       s = s + x % 10;       x = x / 10;    }    cout

Print 1 to 100 in C++, without loop and recursion

Samual Sam

Samual Sam

Updated on 26-Jun-2020 08:11:52

691 Views

There are several methods to print numbers without using loops like by using recursive function, goto statement and creating a function outside main() function.Here is an example to print numbers using goto statement in C++ language, Example Live Demo#include using namespace std; int main() {    int count=1;    int ... Read More

Java Program to convert Java String to Float Object

Samual Sam

Samual Sam

Updated on 26-Jun-2020 08:11:35

178 Views

To convert String to Float Object, you can use a method Float.valueOf() method or you can even achieve this without using the in-built method.Let us see both the examples.The following is an example that converts String to Float Object using Float.valueOf() method.Example Live Demopublic class Demo {    public static void ... Read More

isupper() function in C Language

Samual Sam

Samual Sam

Updated on 26-Jun-2020 08:10:38

2K+ Views

The function isupper() is used to check that the character is uppercase or not. It returns non-zero value if successful otherwise, return zero. It is declared in “ctype.h” header file.Here is the syntax of isupper() in C language, int isupper(int character);Here, character − The character which is to be checked.Here ... Read More

How can I convert string to double in C/C++?

Samual Sam

Samual Sam

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

820 Views

Here is an example to convert a string to double.Example Live Demo#include using namespace std; int main() {    char s[20] = "18.2894 is a number";    char *p;    double result;    result = strtod(s, &p);    cout

Java Program to display previous month from GregorianCalendar

Samual Sam

Samual Sam

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

2K+ Views

For GregorianCalendar class, import the following package.import java.util.GregorianCalendar;Create an object.GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance();Now, use the following field and add() method with a negative one (-1) to display the previous month.cal.add((GregorianCalendar.MONTH), -1)Example Live Demoimport java.util.Calendar; import java.util.GregorianCalendar; public class Demo {    public static void main(String[] a) {       ... Read More

Set all the background image properties in one section with CSS

Samual Sam

Samual Sam

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

97 Views

The CSS background property is used to set all the background image properties in one section.ExampleYou can try to run the following code to implement the background property:Live Demo                    #demo {             background: lightblue url("https://www.tutorialspoint.com/css/images/css-mini-logo.jpg") ... Read More

memcpy() function in C/C++

Samual Sam

Samual Sam

Updated on 26-Jun-2020 08:08:37

5K+ Views

The function memcpy() is used to copy a memory block from one location to another. One is source and another is destination pointed by the pointer. This is declared in “string.h” header file in C language. It does not check overflow.Here is the syntax of memcpy() in C language, void ... Read More

ungetc() in C/C++

Samual Sam

Samual Sam

Updated on 26-Jun-2020 08:06:26

181 Views

The function ungetc() takes a character and pushes it back to the stream so that the character could be read again.Here is the syntax of ungetc() in C language, int ungetc(int character, FILE *stream)Here, character − The character to be pushed back to stream.stream − The pointer to the file ... Read More

Advertisements