Sunidhi Bansal has Published 1101 Articles

Reduce the array to a single element with the given operation in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 03-Nov-2021 05:26:04

132 Views

Given an integer variable Number as input. Let us consider an array containing elements in the range 1 to Number in sorted order. If we perform an operation on an array such that at each step the elements at odd positions are removed. Then the goal is to perform this ... Read More

C Program to Redeclaration of global variable

Sunidhi Bansal

Sunidhi Bansal

Updated on 03-Nov-2021 05:22:57

424 Views

We will understand how C and C++ behave differently in case we re-declare a global variable without initializing, redeclaring global variables with initialization, redeclaring global variables and initializing them twice. Also, we will repeat above combinations with local variables.1. A) C program : Redeclaring Global variables with no initialization#include ... Read More

Recursive Selection Sort in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 03-Nov-2021 05:14:49

6K+ Views

Selection Sort is one of the sorting algorithms used to sort data by iterating an array from the beginning and replacing each element with the smallest element in the list. As we move forward the left array is sorted, and the right array is unsorted. Each move places the next ... Read More

Reverse a number using stack in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 03-Nov-2021 05:11:32

2K+ Views

We are given an integer number Num as input. The goal is to find the reverse of the number using stack.Stack:- A stack is a data structure in C++ which stores data in LIFO ( Last in First Out) manner. Major operations of stack are-:Declaration-: stack stck; //stck is ... Read More

Recursive Programs to find Minimum and Maximum elements of array in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 03-Nov-2021 05:07:30

11K+ Views

We are given an integer array Arr[] as input. The goal is to find maximum and minimum elements among the array using recursive methods.Since we are using recursion, we will traverse the whole array till we reach length=1 then return A[0] which forms the base case. Else compare current element ... Read More

Recursive Program for Binary to Decimal in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 03-Nov-2021 05:03:49

1K+ Views

We are given a string containing a binary number. The goal is to find the equivalent decimal number using the recursive method.A binary number can be converted to decimal using following method-: Traverse from LSB to MSB and multiply each with power of 2i Where 0

Recursive program to print formula for GCD of n integers in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Nov-2021 08:29:54

132 Views

We are given an integer as input. The goal is to print the formula of GCD of n numbers using recursion.We know that the GCD of three numbers say a1, b1 and c1 will be gcd(a1, gcd(b1, c1)).Similarly for more than three numbers, gcd can be obtained by formula as ... Read More

Recursive program to check if number is palindrome or not in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Nov-2021 08:28:12

5K+ Views

We are given an integer as input. The goal is to find whether the input number Num is a palindrome or not using recursion.To check if a number is palindrome, reverse that number and check if both numbers are the same or not. If the reversed number is equal to ... Read More

Recursive program for prime number in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Nov-2021 08:26:06

5K+ Views

We are given an integer as input. The goal is to find whether the input number Num is a prime or non-prime using recursion.To check if a number is prime or not, start traversing from i=2 to i

Recursive Implementation of atoi() in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 02-Nov-2021 08:20:05

869 Views

We are given a string containing a number. The goal is to find the equivalent number using the recursive atoi() method. int atoi(const char *str) converts the string argument str to an integer (type int).Example-:Input − Str[] = "58325"Output − The Equivalent decimal is :58325Explanation − The string contains the equivalent number 58325Input − ... Read More

Previous 1 ... 3 4 5 6 7 ... 111 Next
Advertisements