Samual Sam has Published 2492 Articles

C++ Programs To Create Pyramid and Pattern

Samual Sam

Samual Sam

Updated on 24-Jun-2020 08:08:59

1K+ Views

There are many different pyramid patterns that can be created in C++. These are mostly created using nested for loops. Some of the pyramids that can be created are as follows.Basic Pyramid PatternThe code to create a basic pyramid is given as follows.Example Live Demo#include using namespace std; int main() ... Read More

C++ program to Find Sum of Natural Numbers using Recursion

Samual Sam

Samual Sam

Updated on 24-Jun-2020 08:06:47

2K+ Views

The natural numbers are the positive integers starting from 1.The sequence of natural numbers is −1, 2, 3, 4, 5, 6, 7, 8, 9, 10……The program to find the sum of first n natural numbers using recursion is as follows.Example Live Demo#include using namespace std; int sum(int n) {   ... Read More

C++ Program to Calculate Average of Numbers Using Arrays

Samual Sam

Samual Sam

Updated on 24-Jun-2020 08:04:50

7K+ Views

Average of numbers is calculated by adding all the numbers and then dividing the sum by count of numbers available.An example of this is as follows.The numbers whose average is to be calculated are: 10, 5, 32, 4, 9 Sum of numbers = 60 Average of numbers = 60/5 = ... Read More

C++ Program to Multiply Two Matrix Using Multi-dimensional Arrays

Samual Sam

Samual Sam

Updated on 24-Jun-2020 08:02:07

4K+ Views

A matrix is a rectangular array of numbers that is arranged in the form of rows and columns.An example of a matrix is as follows.A 3*3 matrix has 3 rows and 3 columns as shown below −8 6 3 7 1 9 5 1 9A program that multiplies two matrices ... Read More

C++ Program to Subtract Complex Number using Operator Overloading

Samual Sam

Samual Sam

Updated on 24-Jun-2020 07:59:53

2K+ Views

Operator overloading can be done with most of the built-in operators in C++. The overloaded operators are functions with the keyword operator followed by the operator symbol that is defined. The overloaded operators have a return type and a parameter list like any function.A program that subtracts complex numbers using ... Read More

C++ Program to Multiply two Numbers

Samual Sam

Samual Sam

Updated on 24-Jun-2020 07:58:02

2K+ Views

Multiplication of two numbers a and b yields their product. Value of a is added as many times as the value of b to get the product of a and b.For example.5 * 4 = 20 7 * 8 = 56 9 * 9 = 81Program to Multiply two Numbers ... Read More

C++ Program to Check Prime Number By Creating a Function

Samual Sam

Samual Sam

Updated on 24-Jun-2020 07:56:40

5K+ Views

A prime number is a whole number that is greater than one and the only factors of a prime number should be one and itself.Some of the first prime numbers are −2, 3, 5, 7, 11, 13 ,17A program to check if a number is prime or not using a ... Read More

C++ program to Calculate Factorial of a Number Using Recursion

Samual Sam

Samual Sam

Updated on 24-Jun-2020 07:54:31

1K+ Views

Factorial of a non-negative integer n is the product of all the positive integers that are less than or equal to n.For example: The factorial of 7 is 5040.7! = 7 * 6 * 5 * 4 * 3 * 2 *1 7! = 5040Let us see the code to ... Read More

C++ Program to Convert Binary Number to Decimal and vice-versa

Samual Sam

Samual Sam

Updated on 24-Jun-2020 07:49:03

2K+ Views

In a computer system, the binary number is expressed in the binary numeral system while the decimal number is in the decimal numeral system. The binary number is in base 2 while the decimal number is in base 10.Examples of decimal numbers and their corresponding binary numbers are as follows ... Read More

C++ Program to Calculate Sum of Natural Numbers

Samual Sam

Samual Sam

Updated on 24-Jun-2020 07:36:14

2K+ Views

The natural numbers are the positive integers starting from 1.The sequence of natural numbers is −1, 2, 3, 4, 5, 6, 7, 8, 9, 10……Sum of the first n natural numbers can be calculated using the for loop or the formula.Programs specifying both of these methods are given as follows ... Read More

Advertisements