Yahoo India Web Search

Search results

  1. Jun 30, 2024 · Two Dimensional Array in C++ Programming. Data_type name_of_Array [ Number of rows] [ Number of columns] The square brackets in the 2D array hold the number of rows and columns in the array. If the value of each row and column is one, then the array consists of a single element. For example: int my_Array [1] [1] = {2}.

  2. 3 days ago · The algorithm for linear search can be broken down into the following steps: Start: Begin at the first element of the collection of elements. Compare: Compare the current element with the desired element. Found: If the current element is equal to the desired element, return true or index to the current element.

  3. Jun 24, 2024 · The left shift (<<) is a binary operator that takes two numbers, left shifts the bits of the first operand, and the second operand decides the number of places to shift. In other words, left-shifting an integer “a” with an integer “b” denoted as ‘(a<<b)’ is equivalent to multiplying a with 2^b (2 raised to power b). Syntax.

  4. Jul 1, 2024 · In C, we can use function pointers to avoid code redundancy. For example a simple qsort () function can be used to sort arrays in ascending order or descending or by any other order in case of array of structures. Not only this, with function pointers and void pointers, it is possible to use qsort for any data type. C++.

  5. Jun 27, 2024 · Dynamic Arrays in C, can be initialized at the time of their declaration by using the malloc () function that allocates a block of memory and returns a pointer to it, or calloc () function that allocates memory for the given size and initializes all bytes to zero. After allocation, we can initialize the elements of the array using the for loop.

  6. Jun 24, 2024 · Variable length arrays are a feature where we can allocate an auto array (on stack) of variable size. It can be used in a typedef statement. C supports variable-sized arrays from the C99 standard. For example, the below program compiles and runs fine in C. Syntax of VLAs in C void fun(int size) {int arr[size]; // code}

  7. 3 days ago · Given an array arr [] of size n, return an equilibrium index (if any) or -1 if no equilibrium index exists. The equilibrium index of an array is an index such that the sum of elements at lower indexes is equal to the sum of elements at higher indexes. Examples: Input : arr [] = {-7, 1, 5, 2, -4, 3, 0} Output : 3.