The Wayback Machine - https://web.archive.org/web/20230310183234/https://www.geeksforgeeks.org/basic/563/
Skip to content
All Basic Articles
Write an efficient program to find the sum of contiguous subarray within a one-dimensional array of numbers that has the largest sum.    Recommended: Please… Read More
Given an array of positive integers. All numbers occur an even number of times except one number which occurs an odd number of times. Find… Read More
Given an array arr[] consisting of positive integers that occur even number of times, except one number, which occurs odd number of times. The task… Read More
Write a recursive function to print the reverse of a given string. Code:  C++ // C++ program to reverse a string using recursion #include <bits/stdc++.h> using… Read More
Given a number n, find the result after multiplying it by 7. Example: Input: n=8Output: 56 Naive Approach: The basic way to solve this is… Read More
Write a program to reverse the digits of an integer. Examples :   Input : num = 12345 Output: 54321 Input : num = 876 Output:… Read More
Algorithm: roundNo(num) 1. If num is positive then add 0.5. 2. Else subtract 0.5. 3. Type cast the result to int and return. Example: num… Read More
First of all we have to understand how printf() function works. Prototype of printf() function is: int printf( const char *format , ...) Parameter format:… Read More
Predict the output of the below program.  C++ #include <iostream> using namespace std;   int main() {     int x = 5;     int * const ptr… Read More
Predict the output of the below program   C++ #include <iostream> using namespace std;   #define square(x) x*x   int main() {   int x;   x… Read More
Given two strings string1 and string2, remove those characters from the first string(string1) which are present in the second string(string2). Both strings are different and… Read More
Write a GetNth() function that takes a linked list and an integer index and returns the data value stored in the node at that index… Read More
Algorithm: Let input string be "geeksforgeeks" 1: Construct character count array from the input string. count['e'] = 4 count['g'] = 2 count['k'] = 2 …… 2: Print all the indexes from the constructed array which have value greater than 0.
Given a string S, the task is to remove all the duplicates in the given string. Below are the different methods to remove duplicates in a… Read More
Given a number, find the sum of its digits. Examples :  Input: n = 687Output: 21 Input: n = 12Output: 3 Recommended Practice Sum Of… Read More
Given a number, find sum of its digits.Example :   Input : n = 687 Output : 21 Input : n = 12 Output : 3… Read More
Given a number, find the sum of its digits.Example :  Input : n = 687Output : 21 Input : n = 12Output : 3 1.… Read More
If we take a look at this problem carefully, we can see that the idea of “loop” is to track some counter value, e.g., “i… Read More
Given string str. The task is to find the maximum occurring character in the string str. Examples: Input: geeksforgeeksOutput: eExplanation: ‘e’ occurs 4 times in the… Read More

Start Your Coding Journey Now!