## C++ for Beginners: C++ Program to Calculate Power of a Number

Hits: 12 (C++ programming Example for Beginners) C++ Program to Calculate Power of a Number In this article, you will learn to compute power to a number manually, and by using pow() function. This program takes two numbers from the user (a base number and an exponent) and calculates the power. Power of a number …

## C++ for Beginners: C++ Program to Find LCM

Hits: 15 (C++ programming Example for Beginners) C++ Program to Find LCM Examples on different ways to calculate the LCM (Lowest Common Multiple) of two integers using loops and decision making statements. LCM of two integers a and b is the smallest positive integer that is divisible by both a and b. Example 1: Find LCM #include <iostream> using namespace std; int main(){ …

## C++ for Beginners: C++ Program to Find GCD

Hits: 20 (C++ programming Example for Beginners) C++ Program to Find GCD Examples on different ways to calculate GCD of two integers (for both positive and negative integers) using loops and decision making statements.   The largest integer which can perfectly divide two integers is known as GCD or HCF of those two numbers. Example …

## C++ for Beginners: C++ Program to Generate Multiplication Table

Hits: 107 (C++ programming Example for Beginners) C++ Program to Generate Multiplication Table Example to generate the multiplication table of a number (entered by the user) using for loop. Example 1: Display Multiplication table up to 10 #include <iostream> using namespace std; int main(){ int n; cout << “Enter a positive integer: “; cin >> …

## C++ for Beginners: C++ Program to Find Factorial

Hits: 14 (C++ programming Example for Beginners) C++ Program to Find Factorial The factorial of a positive integer n is equal to 1*2*3*…n. You will learn to calculate the factorial of a number using for loop in this example. For any positive number n, it’s factorial is given by: factorial = 1*2*3…*n Factorial of negative number …

## C++ for Beginners: C++ Program to Calculate Sum of Natural Numbers

Hits: 5 (C++ programming Example for Beginners) C++ Program to Calculate Sum of Natural Numbers In this example, you’ll learn to calculate the sum of natural numbers. To understand this example, you should have the knowledge of the following C++ programming topics: C++ for Loop Positive integers 1, 2, 3, 4… are known as natural numbers. This …

## C++ for Beginners: C++ Program to Find Largest Number Among Three Numbers

Hits: 8 (C++ programming Example for Beginners) C++ Program to Find Largest Number Among Three Numbers In this example, you’ll learn to find the largest number among three numbers using if, if else and nested if else statements. To understand this example, you should have the knowledge of the following C++ programming topics: C++ if, if…else and …

## C++ for Beginners: C++ Program to Check Whether a character is Vowel or Consonant

Hits: 20 (C++ programming Example for Beginners) C++ Program to Check Whether a character is Vowel or Consonant. In this example, if…else statement is used to check whether an alphabet entered by the user is a vowel or a constant. To understand this example, you should have the knowledge of the following C++ programming topics: C++ if, …

## C++ for Beginners: C++ Program to Check Whether Number is Even or Odd

Hits: 4 (C++ programming Example for Beginners) C++ Program to Check Whether Number is Even or Odd In this example, if…else statement is used to check whether a number entered by the user is even or odd. To understand this example, you should have the knowledge of the following C++ programming topics: C++ if, if…else and Nested …

## C++ for Beginners: C++ Program to Swap Two Numbers

Hits: 7 (C++ programming Example for Beginners) C++ Program to Swap Two Numbers This example contains two different techniques to swap numbers in C programming. The first program uses temporary variable to swap numbers, whereas the second program doesn’t use temporary variables. Example 1: Swap Numbers (Using Temporary Variable) #include <iostream> using namespace std; int …

## C++ for Beginners: C++ Program to Find Size of int, float, double and char in Your System

Hits: 7 (C++ programming Example for Beginners) C++ Program to Find Size of int, float, double and char in Your System his program declares 4 variables of type int, float, double and char. Then, the size of each variable is evaluated using sizeof operator. To find the size of variable,  sizeof operator is used. sizeof(dataType); Example: …

## C++ for Beginners: C++ Program to Find Quotient and Remainder

Hits: 37 (C++ programming Example for Beginners) C++ Program to Find Quotient and Remainder In this example, you will learn to find the quotient and remainder of a given dividend and divisor. In this program, user is asked to enter two integers (divisor and dividend) and computes the quotient and remainder. To compute quotient and …

## C++ for Beginners: C++ Program to Add Two Numbers

Hits: 9 (C++ programming Example for Beginners) C++ Program to Add Two Numbers In this program, user is asked to enter two integers. Then, the sum of those two integers is stored in a variable and displayed on the screen. Primary tabs Example: Program to Add Two Integers #include <iostream> using namespace std; int main(){ …

## C++ for Beginners: C++ Program to Print Number Entered by User

Hits: 17 (C++ programming Example for Beginners) C++ Program to Print Number Entered by User In this example, you’ll learn to print the number entered by a user using C++ cout statement. Example: Print Number Entered by User #include <iostream> using namespace std; int main(){ int number; cout << “Enter an integer: “; cin >> …

## C++ for Beginners: C++ Templates

Hits: 25 (C++ programming Example for Beginners) C++ Templates In this article, you’ll learn about templates in C++. You’ll learn to use the power of templates for generic programming. Templates are powerful features of C++ which allows you to write generic programs. In simple terms, you can create a single function or a class to …