Found 33676 Articles for Programming

C++ Program to get the last item from the array

Arnab Chakraborty
Updated on 13-Dec-2022 15:08:49

8K+ Views

To store several elements of the same type in locations that are sequentially accessible or in a manner that allows for sequential access. The array is among the best options. For storing data, almost any computer language, array, or related data structure is available. Because fundamental operations like insert, remove, traverse, and update take linear time to complete, arrays are linear data structures. It is also simple to access array items. This article will demonstrate how to choose the last element in a C++ array. Understanding the concept with examples Given array A = [10, 14, 65, 85, 96, 12, ... Read More

C++ Program to get the first item from the array

Arnab Chakraborty
Updated on 13-Dec-2022 15:05:20

3K+ Views

To hold multiple elements of the same type in consecutive locations or in such a way that can be accessed sequentially. The array is one of the greatest choices. Almost any programming languages, arrays, or similar data structures are available for data holding. Arrays are linear data structure because basic operations like insert, delete, traverse, and update takes linear time to execute. Accessing array elements are also an easy task. In this article, we will see how to pick the first item from an array in C++. Understanding the concept with examples Given array A = [10, 14, 65, 85, ... Read More

C++ Program to get the subarray from an array using a specified range of indices

Arnab Chakraborty
Updated on 13-Dec-2022 15:03:51

12K+ Views

A sequence of memory sections is used to store homogeneous data in an array, a linear sequential data structure. Similar to other data structures, an array needs to have specific qualities to insert, delete, traverse, and update elements efficiently. In C++, our arrays are static. There are also a few dynamic array structures available in C++. In this article, we will see how to get a subarray from a bigger array using starting and ending indices in C++. Understanding the concept with examples Given array A = [10, 14, 65, 85, 96, 12, 35, 74, 69] Given two indices 2 ... Read More

Swift program to get the remainder of float numbers using library function

Ankita Saini
Updated on 13-Dec-2022 14:59:47

330 Views

This tutorial will discuss how to write swift program to get the remainder of float numbers using library function. A number with fractional component is known as float numbers. For example, 34.5, 2.1, 0.2, etc. We can divide two float numbers with each other to find the remainder and quotient. Remainder is the value left after dividing a number by another number. Below is a demonstration of the same − Input Suppose our given input is − Num1 = 0.16 Num2 = 0.04 Output The desired output would be − Remainder = 0.0 To find the remainder of ... Read More

C++ Program to push an array into another array

Arnab Chakraborty
Updated on 13-Dec-2022 15:02:36

7K+ Views

A linear sequential data structure called an array is used to store homogeneous data in a series of memory regions. An array needs to have certain features to insert, delete, traverse, and update elements effectively, just like other data structures do. Our arrays in C++ are static. In addition, C++ offers a few dynamic array structures. There may be a maximum of Z elements that can be stored inside a static array. And there are currently n elements in it. In this article, we will see how to push the elements of one array inside another array in C++. Understanding ... Read More

C++ Program to append an element into an array

Arnab Chakraborty
Updated on 04-Oct-2023 12:16:39

50K+ Views

An array is a linear sequential data structure to hold homogeneous data in consecutive memory locations. Like other data structures, an array also must-have features to insert, delete, traverse and update elements in some efficient way. In C++, our arrays are static. There are a few dynamic array structures also available in C++. For a static array, there may be a Z number of elements that can be stored inside that array. And till now we have n elements into it. In this article, we will see how to insert an element at the end of an array (which is ... Read More

Swift program to print spiral pattern

Ankita Saini
Updated on 13-Dec-2022 14:55:44

387 Views

This tutorial will discuss how to write swift program to print spiral pattern. Numeric pattern is a sequence of numbers which is used to develop different patterns or shapes like pyramid, rectangle, cross, etc. These numeric patterns are generally used to understand or practice the program flow controls, also they are good for logical thinking. To create a spiral pattern of numbers, we can use any of the following methods − Using nested for loop Using stride Function Below is a demonstration of the same − Input Suppose our given input is − Num = 6 Output ... Read More

C++ Program to Access private members of a class

Arnab Chakraborty
Updated on 13-Dec-2022 14:54:09

26K+ Views

Private members of a class are only accessed by the members of the class. This is done to preserve the object-oriented paradigm encapsulation, which ensures data and its related functions are kept in one unit and only accessible only from a member of that class. C++ has three different access specifiers to specify the visibility of the members of a class. The three access specifiers are − Public − If a member of a class has the visibility public, then the members can be accessed from any other class. Private − Class members having private visibility can be accessed from ... Read More

C++ Program to Create Custom Exception

Alshifa Hasnain
Updated on 18-Mar-2025 17:55:41

4K+ Views

In this article, we learn to create custom-made, user−defined exceptions in C++. Exceptions are a core concept of C++. They occur when an unwanted or impossible operation occurs during execution. Handling these unwanted or impossible operations is known as exception handling in C++. What is Exception Handling? Exception handling is mainly done using three specific keywords: ' try’, ‘catch’, and ‘throw’. The ‘try’ keyword is used to execute code that may encounter an exception, the ‘catch’ keyword is used to handle such exceptions, and the ‘throws’ keyword is used to create an exception. Exception Types Exceptions in C++ can be divided ... Read More

Swift program to convert array to a string

Ankita Saini
Updated on 13-Dec-2022 14:48:23

3K+ Views

This tutorial will discuss how to write swift program to convert array to a string. String is an ordered collection of characters. For example: “TutorialsPoint”, “Pinky”, etc. To create a string type variable we use String keyword. var str : String Array is a collection of similar data types. Like any array of integer can contain only integer values, it does not accept string values. var arr = [Int] To convert an array to a string we can use any of the following method. Below is a demonstration of the same − Input Suppose our given input is ... Read More

Advertisements