# Tag Archives: C++ Basic Programs

C++ Basic Programs

Given two integers x and n, write a function to compute xn. We may assume that x and n are small and overflow doesn’t happen.… Read More
Method 1 (Using Nested Loops):We can calculate power by using repeated addition. For example to calculate 5^6. 1) First 5 times add 5, we get 25. (5^2) 2)… Read More
The Fibonacci numbers are the numbers in the following integer sequence.0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, …….. In… Read More
Write a program to reverse the digits of an integer. Examples :   Input : num = 12345 Output: 54321 Input : num = 876 Output:… Read More
Given a natural number n, print all distinct divisors of it. Examples: Input : n = 10 Output: 1 2 5 10 Input: n =… Read More
Given a number n, find the sum of first natural numbers. Examples :  Input: n = 3 Output: 6 Explanation: Note that 1 + 2… Read More
A positive integer with digits a, b, c, d… is called an Armstrong number of order n if following condition is satisfied.  abcd... = an… Read More
GCD (Greatest Common Divisor) or HCF (Highest Common Factor) of two numbers is the largest number that divides both of them.  For example GCD of… Read More
Given a number n, find sum of first n natural numbers. To calculate the sum, we will use a recursive function recur_sum().Examples :   Input: 3… Read More
Given a prime number . The task is to check if it is possible to express as sum of two separate prime numbers.Note: The range of N… Read More
Given a large number N, task is to find the factorial of N using recursion. Factorial of a non-negative integer is the multiplication of all… Read More
Given a quadratic equation in the form ax2 + bx + c, find roots of it.  Examples : Input  :  a = 1, b =… Read More
Given a positive integer N. The task is to write a C++ program to check if the number is prime or not.  Definition:  A prime number… Read More
A cube is a 3-dimensional box-like figure represented in the 3-dimensional plane. Cube has 6 squared-shape equal faces. Each face meets another face at 90… Read More
Given two positive integers i.e, the length and breadth of the rectangle, the task is to find the length of the Diagonal of a Rectangle.… Read More
{"ft_lang_label":"__label__en","ft_lang_prob":0.7816612,"math_prob":0.9956392,"size":2177,"snap":"2023-14-2023-23","text_gpt3_token_len":585,"char_repetition_ratio":0.16244823,"word_repetition_ratio":0.024271844,"special_character_ratio":0.2792834,"punctuation_ratio":0.1570248,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99863815,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-03-27T16:46:36Z\",\"WARC-Record-ID\":\"<urn:uuid:b30ef768-774d-4979-a3fc-6434a7939a5c>\",\"Content-Length\":\"190624\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:6a3d41eb-7c13-477e-a63f-42c3725598e7>\",\"WARC-Concurrent-To\":\"<urn:uuid:e0e5e5cd-df0b-462f-af55-e3c38928e3de>\",\"WARC-IP-Address\":\"44.228.100.190\",\"WARC-Target-URI\":\"https://origin.geeksforgeeks.org/tag/cpp-basic-programs/\",\"WARC-Payload-Digest\":\"sha1:SBV7QTTIXBIPJFQKSCP55QM7LAQSGXOX\",\"WARC-Block-Digest\":\"sha1:7AULAOKBERAZRH5VMHLRBNEB25ZR6A26\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-14/CC-MAIN-2023-14_segments_1679296948673.1_warc_CC-MAIN-20230327154814-20230327184814-00294.warc.gz\"}"}