What is a String Literal in C++

Arjun Thakur
Updated on 27-Feb-2020 05:08:03

542 Views

A string literal or anonymous string is a type of literal in programming for the representation of a string value within the source code. More simply put, a string literal is a bit of text between double quotes. For example,const char* var = "Hello";In this definition of var, "Hello" is a string literal. Using const in this way means you can use var to access the string but not to change it. A C++ compiler handles it in the same way as it would handle a character array.

Importance of transferTo Method of InputStream in Java 9

raja
Updated on 26-Feb-2020 13:20:24

2K+ Views

The transferTo() method has been added to the InputStream class in Java 9. This method has been used to copy data from input streams to output streams in Java. It means it reads all bytes from an input stream and writes the bytes to an output stream in the order in which they are reading.Syntaxpublic long transferTo(OutputStream out) throws IOExceptionExampleimport java.util.Arrays; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; public class TransferToMethodTest {    public void testTransferTo() throws IOException {       byte[] inBytes = "tutorialspoint".getBytes();       ByteArrayInputStream bis = new ByteArrayInputStream(inBytes);       ByteArrayOutputStream bos = new ... Read More

Generate Prime Numbers Using Python

Pythonista
Updated on 26-Feb-2020 12:46:08

5K+ Views

A prime number is the one that is not divisible by any other number except 1 and itself.In Python % modulo operator is available to test if a number is divisible by other. Assuming we have to find prime numbers between 1 to 100, each number (let us say x) in the range needs to be successively checked for divisibility by 2 to x-1. This is achieved by employing two nested loops.for x in range(1,101): for y in range(2,x): if x%y==0:break else: print (x,sep=' ', end=' ')Above code generates prime numbers between 1-1001 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97

Stop Infinite Loop in Python Using Keyboard Command

Pythonista
Updated on 26-Feb-2020 12:44:52

420 Views

Any loop is formed to execute a certain number of times or until a certain condition is satisfied. However, if the condition doesn't arise, loop keeps repeating infinitely. Such an infinite loop needs to be forcibly stopped by generating keyboard interrupt. Pressing ctrl-C stops execution of infinite loop>>> while True: print ('hello') hello hello hello hello hello hello Traceback (most recent call last): File "", line 2, in print ('hello') KeyboardInterrupt

Different Types of Operators in C++

Krantik Chavan
Updated on 26-Feb-2020 12:33:01

481 Views

There are many types of operators in C++. These can be broadly categorized as: arithmetic, relational, logical, bitwise, assignment and other operators.Arithmetic OperatorsAssume variable A holds 10 and variable B holds 20, then −OperatorDescription       +        Adds two operands. A + B will give 30-Subtracts second operand from the first. A - B will give -10*Multiplies both operands. A * B will give 200/Divides numerator by de-numerator. B / A will give 2%Modulus Operator and remainder of after an integer division. B % A will give 0++Increment operator, increases integer value by one. A++ will give ... Read More

Insert in Deque in C++ STL

Sunidhi Bansal
Updated on 26-Feb-2020 12:24:12

708 Views

Given is the task to show the functionality of Deque insert( ) function in C++ STLWhat is Deque?Deque is the Double Ended Queues that are the sequence containers which provides the functionality of expansion and contraction on both the ends. A queue data structure allow user to insert data only at the END and delete data from the FRONT. Let’s take the analogy of queues at bus stops where the person can be inserted to a queue from the END only and the person standing in the FRONT is the first to be removed whereas in Double ended queue the ... Read More

Clear Function in C++ STL List

Sunidhi Bansal
Updated on 26-Feb-2020 12:18:36

4K+ Views

In this article we will be discussing the working, syntax and examples of list::clear() function in C++.What is a List in STL?List is a data structure that allows constant time insertion and deletion anywhere in sequence. Lists are implemented as doubly linked lists. Lists allow non-contiguous memory allocation. List perform better insertion extraction and moving of element in any position in container than array, vector and deque. In List the direct access to the element is slow and list is similar to forward_list, but forward list objects are single linked lists and they can only be iterated forwards.What is clea()?list::clear() ... Read More

List Remove Function in C++ STL

Sunidhi Bansal
Updated on 26-Feb-2020 12:15:04

13K+ Views

In this article we will be discussing the working, syntax and examples of remove() function in C++.What is a List in STLList is a data structure that allows constant time insertion and deletion anywhere in sequence. Lists are implemented as doubly linked lists. Lists allow non-contiguous memory allocation. List perform better insertion extraction and moving of element in any position in container than array, vector and deque. In List the direct access to the element is slow and list is similar to forward_list, but forward list objects are single linked lists and they can only be iterated forwards.What is remove()remove() ... Read More

Deque Rend in C++ STL

Sunidhi Bansal
Updated on 26-Feb-2020 12:10:39

186 Views

Given is the task to show the functionality of Deque rend( ) function in C++ STLWhat is Deque?Deque is the Double Ended Queues that are the sequence containers which provides the functionality of expansion and contraction on both the ends. A queue data structure allow user to insert data only at the END and delete data from the FRONT. Let’s take the analogy of queues at bus stops where the person can be inserted to a queue from the END only and the person standing in the FRONT is the first to be removed whereas in Double ended queue the ... Read More

Deque rbegin in C++ STL

Sunidhi Bansal
Updated on 26-Feb-2020 12:06:59

149 Views

Given is the task to show the functionality of Deque rbegin( ) function in C++ STLWhat is Deque?Deque is the Double Ended Queues that are the sequence containers which provides the functionality of expansion and contraction on both the ends. A queue data structure allow user to insert data only at the END and delete data from the FRONT. Let’s take the analogy of queues at bus stops where the person can be inserted to a queue from the END only and the person standing in the FRONT is the first to be removed whereas in Double ended queue the ... Read More

Advertisements