isprint Function in C++

Samual Sam
Updated on 26-Jun-2020 07:42:01

92 Views

The function isprint() is predefined function and it checks that the passed characters are printable or not. It returns non-zero value, if successful otherwise, zero. This function is declared in “cctype” header file.Here is the syntax of isprint() in C++ language,int isprint(int character);Here,character − The character is to be checked.Here is an example of isprint() in C++ language,Example Live Demo#include #include using namespace std; int main() {    int val1 = 28;    int val2 = 's';    int val3 = '';    if(isprint(val1))    cout

Difference Between x++ and ++x in Java Programming

Arjun Thakur
Updated on 26-Jun-2020 07:41:18

739 Views

x++ automatically handles the type casting where as x= x + 1 needs typecasting in case of x is not an int variable. See the example below.Example Live Demopublic class Tester {    public static void main(String args[]) {       byte b = 2;       //Type casting is required       //as 1 is int and b is byte variable       b = (byte) (b + 1);       System.out.println(b);       byte b1 = 2;       //Implcit type casting by the compiler       b1++;       System.out.println(b1);    } }Output3 3

JVM Creates Object of Main Class in Java

Ankith Reddy
Updated on 26-Jun-2020 07:40:55

531 Views

As we know that Java needs main() method to be static in the public class to make it executable. The prime reason for this requirement is to make JVM enable to call the main() method without creating an object. That simply means that JVM does not create the object of the Main class which contains the main() method. To justify the same, we can make the Main class containing the main method as abstract and program still runs.Following example showcases the same. Here we have made the main class abstract.Exampleabstract public class Tester {    public static void main(String args[]) ... Read More

Fibonacci of Large Number in Java

George John
Updated on 26-Jun-2020 07:39:23

770 Views

Fibonacci numbers of Fibonacci series grows exponentially and can be very large for large numbers like 500 or 1000. To handle such number, long data type is not sufficient. BigInteger can handle large number easily. BigInteger is useful in scenarios where calculations results in data which is out of limit for available primitive data types. See the example below of getting Fibonacci number of 100 and 1000.Example Live Demoimport java.math.BigInteger; public class Tester {    public static void main(String args[]) {       System.out.println("Fibonacci of 100: ");       System.out.println(fibonacci(100));       System.out.println("Fibonacci of 1000: ");     ... Read More

Find Frequency of Each Word in a String in Java

Chandu yadav
Updated on 26-Jun-2020 07:38:47

2K+ Views

In order to get frequency of each in a string in Java we will take help of hash map collection of Java.First convert string to a character array so that it become easy to access each character of string.Now compare for each character that whether it is present in hash map or not in case it is not present than simply add it to hash map as key and assign one as its value.And if character is present than find its value which is count of occurrence of this character in the string (initial we put as 1 when it ... Read More

Find Max and Min Values in Array of Primitives Using Java

Ankith Reddy
Updated on 26-Jun-2020 07:37:59

700 Views

This example shows how to search the minimum and maximum element in an array by using Collection.max() and Collection.min() methods of Collection class.Example Live Demoimport java.util.Arrays; import java.util.Collections; public class Main {    public static void main(String[] args) {       Integer[] numbers = { 8, 2, 7, 1, 4, 9, 5};       int min = (int) Collections.min(Arrays.asList(numbers));       int max = (int) Collections.max(Arrays.asList(numbers));       System.out.println("Min number: " + min);       System.out.println("Max number: " + max);    } }OutputThe above code sample will produce the following result.Min number: 1 Max number: 9Another ... Read More

How Java Objects Are Stored in Memory

Arjun Thakur
Updated on 26-Jun-2020 07:37:24

4K+ Views

A stack and a heap are used for memory allocation in Java. However, the stack is used for primitive data types, temporary variables, object addresses etc. The heap is used for storing objects in memory.Stacks and heaps in Java are explained in more detail as follows −Stack in JavaStacks are used to store temporary variables, primitive data types etc. A block in the stack exists for a variable only as long as the variable exists. After that, the block data is erased and it can be used for storing another variable.

When to Use i++ or ++i in C++

Samual Sam
Updated on 26-Jun-2020 07:36:30

1K+ Views

Increment operators are used to increase the value by one while decrement works opposite. Decrement operator decrease the value by one.Pre-increment (++i) − Before assigning the value to a variable, the value is incremented by one.Post-increment (i++) − After assigning the value to a variable, the value is incremented.Here is the syntax of i++ and ++i in C++ language,++variable_name; // Pre-increment variable_name++; // Post-incrementHere,variable_name −Name of the variable given by user.Here is an example of pre and post increment in C++ language,Example Live Demo#include using namespace std; int main() {    int i = 5;    cout

What is a Nebula and How is it Formed

Shanmukh Pasumarthy
Updated on 26-Jun-2020 07:36:01

640 Views

A nebula is an interstellar cloud of dust made of hydrogen, helium and other ionized gasses. Initially, it was a name given for any diffuse cosmic object, including galaxies past the Milky Way.Most nebulae are of the tremendous size, even a great many light years in diameter. The nebula that is scarcely noticeable to the human eye from Earth would seem bigger, yet not brighter, when near it. The Orion Nebula, the brightest cloud in the sky that involves an area double the diameter of the full Moon, can be seen with the exposed eye yet was missed by early ... Read More

isgreater in C/C++

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

324 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 argument which will be checked with value2.value2 − This is the second argument which is used to check value1 that is greater or not.Here is an example of isgreater().Example Live Demo#include #include using namespace std; int main() {    int val1 = 28;    int val2 = 8;    bool result; ... Read More

Advertisements