Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


C++ Programming

C++ Programming Language Code Examples

Addition, Subtraction, Multiplation, Result to decimal. Reverse second binary operand and Creating an array for addition. Addition of all columns without carry. Final calculations and
String is a "sequence of characters". char data type is used to represent one single character in C++. So if you want to use a String in your program then you can use an "array of chars".
2 const variables row & col are used to define size. If we do not make both const then error found because without "const reserve word" they are behaving as variable. Before placing
Takes input a Character and Check it whether a 'character' is capital letter, small letter, Digit or Special character. 'All characters' like small or capital letters, digits and special characters
The Fibonacci sequence is a series where the next term is the "sum of pervious two terms". The first two terms of the Fibonacci sequence is 0 followed by 1. Fibonacci Numbers: 0, 1, 1,
Get size of the current type. Align depens on the next type and also alignment defined by #pragam pack(#). Offset will be minimum of this size. If the "size of next type" is less than
To achieve Addition of two matrix we need 2 "Dimensional Array" and add their elements with each other, print result on screen. Enter elements of firts matrix. Enter elements of 2.
Combined two strings means add both string with each other, perform this operation using 'library function' or without library function. If first string is 'john' and second string is porter
Alphabets a, e, i, o, u are known as vowels. All other alphabets except these 5 alphabets are known are 'consonants'. C++ sample assumes that the user will enter an Alphabet. Similarly
A 'positive integer' which is only divisible by 1 and itself is known as prime number. So 13 is a prime number because it is only divisible by 1 and 13 but, 15 is not prime number because
Palindrome number is a number that remains the same when its digits are reversed. 16461, for example: we take 121 and reverse it, after revers it is same as original. Get a value from
C++ program performs Naive string matching without using any specific library functions. A text and a Pattern is given as input. Pattern is searched for in a text and all 'instances' of the
Column number of first matrix must be same as the row number of second matrix. Initialize matrix. Print values of the passed matrix and mutiply two matrices and return the resultant
In C++ program, we have the variable i inside "Switch Braces", which means whatever the value of variable i is, the 'corresponding' case block gets executed. We have passed integer
In this example, if...else statement is used to check whether a number entered by the user is "even or odd". Integers which are perfectly "divisible by 2" are called even numbers. And
Smaller elements go left. Larger elements go right. All insertions are as leaf nodes. Remove a leaf node and remove a node with a single child. Remove a node with 2 children, replace
To add digits of any number in C++, we enter the number to add their digits & displays the "Addition Result" of the digits of the entered number on the output screen as shown here
Program takes two numbers (a 'base number' and an 'exponent') and Calculates the Power. The technique works only if the exponent is a positive integer. If you need to find the power
In c++ program, a positive integer is asked to enter which is stored in the variable origNum. The number is copied to variable num. This is done because we need to check the origNum
Write a simple C++ program which have four different functions for "basic operations" like addition, subtraction, division, multiplication. It should be menu based asking user to enter
An "Armstrong Number" is a number that is the 'sum of its own digits' each raised to the power of the number of digits is equal to the number itself. Some Armstrong numbers is 0
Perform addition, subtraction, multiplication and division of any two numbers in 'C++', you have to enter the 'two number' and enter the operator to perform the particular operation
In this control structure we have only one 'if' and one 'else', however we can have multiple 'else if' blocks. This is how it looks: If none of the 'condition is true' then these statements
We have to enter some set of numbers. Now to find occurrence of positive, negative, zero from the given set of numbers, just check all the numbers using for loop whether number
Takes an "arithmetic operator" (+, -, *, /) and two operands from an user and performs the operation on those two operands depending upon the operator entered by user. Program
In this program, user is asked to entered the number of rows r & columns c. The value of r & c should be less than 100 in this program. Then, the program adds these two matrices,
Control statement itself has three parts: for ( "initialization"; test condition; run every time command ). "Initialization" part is performed only once at for loop start. We can initialize a
Takes n number of element from user (where, n is specified by user), stores data in an array and calculates the average of those numbers, program calculates the average if the number
Topological sorting for directed acyclic graph (dag) is a linear ordering of vertices such that for every directed edge 'uv', vertex 'u' comes before v in the ordering. 'Topological Sorting'
Allocating memory for "ODBC" Environment handle. Connecting to the data source "db97" using userid and password. Prepare the SQL statement by assigning it to the "statement"
This is a C++ Program to check whether point lies above, below or on the line. For example, the equation of the line connecting points (2, 2) and (4, 5) is -3x + 2y + 2 = 0. The point (6, 3)
If graph has no odd degree vertex, there is at least one Eulerian Circuit. And if graph as two vertices with odd degree, there is no Eulerian Circuit but at least one Eulerian Path. If graph
We can use "break" statement inside loops to terminate a 'loop & exit' it. In above example loop execution 'continues' until either n>=20 or entered score is negative. This statement
The statement is executed, then expression is evaluated. If it is true, statement is evaluated again, and so on. When 'expression' becomes false, the 'loop terminates'. Experience shows
'C++ Program' to find the minimum spanning tree of the given graph. Kruskal's algorithm is a greedy algorithm in graph theory that finds a "Minimum Spanning Tree" for a connected
Find the minimum spanning tree of the given graph using Prims algorihtm. This algorithm is a "greedy algorithm" that finds a minimum spanning tree for a "Connected Undirected"
Using an adjacency matrix, displays the times at which the 'different times' at which nodes are visited and left thereby producing a linear ordering of vertices in a graph. And A graph is
"Array index" starts with 0, which means the first array element is at index 0, second is at index 1 and so on. We use this information to display the array elements. See the C++ code
A C++ function to find the factorial of a given number using matrix multiplication method. Assigning numbers from "1 to n" to the super diagonal indexes of the matrix and assigning
The second power was described in terms of the area of a square, as in the above formula. It led to the use of the term square to mean raising to the "second power". Thus the area
Give the degree of the polynomiala. Give the value of the coefficients. Give the value of the coefficients. Give the values of the coefficient of polynomialb. Give value to be substituted
This c++ program shows the greatest number between 3 numbers use 'if-else-if' statement. It takes three numbers as input from user and output the greatest number. Enter value first
Full form of Ascii is American Standard Code for Information Interchange. It is a character "Encoding Scheme". Originally based on the English alphabet, every character or number
1:-) As we have seen that any class that has a pure virtual function is an abstract class. 2:-) We cannot create the "instance" of abstract class. For example: If I have written this line
"Partitioning the array" on the basis of values at high as pivot value. Swapping value at high and at the index obtained. Partitioning array using last element as a pivot. And recursively
"Encapsulation" represents binding data and functions into one container. Container hides the details of the data and the way functions process data. In C++, Class is a container that
Ask to enter two time periods and these two periods are stored in structure variables t1 t2 respectively. The computeTimeDifference() Function calculates the Difference Between
Operator is a symbol that is used to perform "mathematical" or "logical" manipulations. +, -, *, /, %, Addition, Subtraction, Division and Multiplication, Modulus, ++, -- Increment and
Any "Programming Language" has a "list" of keywords. C++ Keywords are list of reserved words for this Programming Language. Each keyword has a special meaning and it can not
Simple C++ program to display "Hello, World" on the screen. Since, it's a simple program, it is often used to illustrate the syntax of a c++ programming language. Every C++ program
Any programming language has built in data types. Data types are used to create variables or your new data types. Variable is a amount of memory that has its own name and value.
in C++, "bitwise operators" are similar to the Logic operators, but they perform the same logical operations on bits. All data in memory is represented in the "binary form". Variables
The operator "=" is an "assignment operator" in C++ and it assigns a value to the objects on the left. C++ Language provides capability to combine assignment operator with almost all
Basic "arithmetic operators" are +, -, *, /, %. "Increment operator" is ++ and "decrement operator" is --. These operators can be used as before the variable (prefix) and after the
In C++ language, Encapsulation is achieved using access specifiers. In encapsulation we make all member variables private, provide public "functions" which allow user to work
This is a program of matrix capable of doing several works with two matrices. It can add, subtract, multiply of two matrices and if user wants to see the input entered in 2 matrices
A function is block of code which is used to perform a particular task, for example let's say you are writing a "Larger C++ Program", in that program you want to do a particular
To find the "Largest Element", the first two elements of array are checked and largest of these two element is placed in arr[0]. Then, the first and third elements are checked and
Array is the collection of similar data type, In this c++ program we find duplicate elements from an array, Suppose array have 3, 5, 6, 11, 5 and 7 elements, in this array 5 appear two
This function reads n lines from a file. Returns the amount of bytes read. Try to open txt file. Try to locate the starting line. Set the starting position. Read the lines. Close the file. Return