Ankith Reddy has Published 1070 Articles

How to get default phone number in android?

Ankith Reddy

Ankith Reddy

Updated on 26-Jun-2020 14:14:11

523 Views

This example demonstrate about How to get default phone number in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     In the ... Read More

How to return local array from a C++ function?

Ankith Reddy

Ankith Reddy

Updated on 26-Jun-2020 14:13:36

649 Views

A local array cannot be directly returned from a C++ function as it may not exist in memory after the function call. A way to resolve this is to use a static array in the function. As the lifetime of the static array is the whole program, it can easily ... Read More

Accessing array out of bounds in C/C++

Ankith Reddy

Ankith Reddy

Updated on 26-Jun-2020 14:08:50

1K+ Views

In a language such as Java, an exception such as java.lang.ArrayIndexOutOfBoundsException may occur if an array is accessed out of bounds. But there is no such functionality in C and undefined behaviour may occur if an array is accessed out of bounds.A program that demonstrates this in C is given ... Read More

Why do we assume strncpy insecure in C/C++?

Ankith Reddy

Ankith Reddy

Updated on 26-Jun-2020 14:04:29

468 Views

The function strncpy() is used to copy the specified number of characters to the destination from the source.The following is the syntax of strncpy()char *strncpy( char *destination, char *source, size_t n);Here, destination is the pointer to the destination array where the source string is to be copied, source is the ... Read More

When to use new operator in C++ and when it should not be used?

Ankith Reddy

Ankith Reddy

Updated on 26-Jun-2020 13:58:34

7K+ Views

Use of the new operator signifies a request for the memory allocation on the heap. If the sufficient memory is available, it initializes the memory and returns its address to the pointer variable.The new operator should only be used if the data object should remain in memory until delete is ... Read More

Which is the fastest algorithm to find prime numbers using C++?

Ankith Reddy

Ankith Reddy

Updated on 26-Jun-2020 13:50:52

3K+ Views

The Sieve of Eratosthenes is one of the most efficient ways to find the prime numbers smaller than n when n is smaller than around 10 million.A program that demonstrates the Sieve of Eratosthenes is given as follows.Example#include using namespace std; void SieveOfEratosthenes(int num) {    bool pno[num+1];   ... Read More

Declare variable as constant in C

Ankith Reddy

Ankith Reddy

Updated on 26-Jun-2020 13:44:11

18K+ Views

Variables can be declared as constant using the const keyword or the #define preprocessor directive. Details about these are given as follows.The const keywordVariables can be declared as constants by using the “const” keyword before the datatype of the variable. The constant variables can be initialized once only. The default ... Read More

How to “return an object” in C++?

Ankith Reddy

Ankith Reddy

Updated on 26-Jun-2020 13:34:14

4K+ Views

An object is an instance of a class. Memory is only allocated when an object is created and not when a class is defined.An object can be returned by a function using the return keyword. A program that demonstrates this is given as follows −Example Live Demo#include using namespace std; ... Read More

Block movement without overlap in Z-80

Ankith Reddy

Ankith Reddy

Updated on 26-Jun-2020 13:17:38

98 Views

In this section, we will see how we can use the Zilog Z-80 Microprocessor to move a block of data to another location. There is one assumption, there is sufficient distance between source and destination. So blocks are non-overlapping. Basically the block movement is not exact moving, it is copying ... Read More

What is Interleaving?

Ankith Reddy

Ankith Reddy

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

6K+ Views

Interleaving is a tool that is used to enhance existing error correcting codes so that they can be used to perform burst error corrections as well.Most error correcting codes (ECCs) are designed to correct random errors, i.e. error caused by additive noise that is independent of each other. Burst error ... Read More

Advertisements