Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 

How Can I Write a Program About the Maze Game in C++?

Below are the rules involved in the Programming of a Maze Game :   The maze is made out of walls and a path. The starting point of the maze is marked by the coordinates of the player. Similarly, the exit is marked as a dedicated c...

Learn Basic Structure of C++ Programming for Beginner

Prior to creating a C++ program, one needs to start the C++ IDE. The instructions for starting C++ all depend on the system one is using. This unit assumes that the individual is using the Bloodshed compiler. Incase, one uses a different version ...

Use of const keyword with pointers

//============= A simple program to demonstrate the use of "const" keyword with pointers================== /* * By => Bipin Gosain * Date => 17/4/2016 */ #include <iostream> int main(){ using std:: endl; ...

Namespace in C++.

Namespace In C++ two variables with the same name are not possible in the same scope i.e a name given to specific type or function represent one entity in a particluar scope but with namespaces, there is a possibility to create two variables o...

Default copy constructor in c++

A copy constructor is a special type of constructor by using which we can initialize the data members of a newly created object by existing objects. The compiler provides a default copy constructor.  Syntax of calling a copy constructor is:...

To check a number is perfect square or not using addition operation only.

The problem is that a positive integer n is given and check if it is perfect square or not using only addition operation. // C++ program to check if n is perfect square or not #include<bits/stdc++.h> using namespace ...

To Check if edit distance between two strings is one

 Edit distance between two strings is said to be one when following changes occur:- Adding a character. Deleting a character A character is changed // C++ program to check if given two strings are // at distance one. #incl...

How to check whether a number is in range[low,high] using one comparison?

#include <iostream> using namespace std; // Returns true if x is in range [low..high], else false bool inRange(int low, int high, int x) { return ((x-high)*(x-low) <= 0); } int main() { inRange(10, 100, 25)? cout &...

VIRTUAL FUNCTIONS IN C++

Virtual function is a member function  in base class, which is redefined in the derived class. Virtual function is declared by using the keyword virtual. Syntax of virtual function: class main_Class // denotes the base class of v...

Program to count no of words from given input string.

// C++ program to count no of words from given input string. #include <stdio.h> #define separator 0 #define word 1 unsigned countWords(char *str) // returns number of words in str { int state = separator; unsigned wc = 0; // w...

Reference and Pointers in C++

REFERENCE---  A reference variable is initialized first. A reference variable is defined to indicate a variable and that reference variable can't point to the another variable. References can not be NULL. e.g of reference variable is:...

Foreach loop in C++

Foreach loop is another loop which was introduced in C++ 11. The advantage of foreach loop over other loops is that, it can access elements of an array quickly without performing initialization, testing and increment/decrement, the code...

How to split a string in C++?

// A C++ program for splitting a string using strtok() #include <stdio.h> #include <string.h> int main() { char str[] = "First-Demo-Example"; char *token = strtok(str, "-"); // Returns first token whi...

How to know the average without disclosing the salaries?

Suppose we want to find the average salary of three employee(A,B,C) without disclosing there individual salary.In order to do this see the following algorithm: ALGORITHM : First A will add a random number to it's salary and then tell...

Return maximum occurring character in the input string in C++?

// C++ program to output the maximum occurring character in a string #include<bits/stdc++.h> #define ASCII_SIZE 256 using namespace std; char getMaxOccuringChar(char* str) { int count[ASCII_SIZE] = {0};//create an array to ...

VTABLE and VPTR in C++

VTABLE-  C++ uses a special form of a runtime method  binding to implement virtual functions which is called virtual table. Virtual table is a table of functions used to accomplish function calls in a dynamic binding manner. Virtual bin...

Wrapper class in C++

Wrapper is generally defined as the packaging, or to bound an object. A "wrapper class" is used to manage the resources so that it will be crystal-clear to every one. This wraps the resources by simply wrapping the pointer into an in...

Storage Classes in C++

Storage classes defines the scope of the variable in the function. Storage class specified for a variable shows that for how long time the variable will remain in the program and which section of the program will have the accessibility of the var...

Scope resolution operator

In C++ scope resolution operator is used to define a function outside a class. If a user  has a local variable with same name as global variable and wants to use a global variable the we use the scope resolution operator.   includ...

Program to Detect and Remove Loop in a Linked List in C++?

// C++ program to detect and remove loop using namespace std; struct Node { int key; struct Node *next; }; Node *newNode(int key) //Function to create a node { Node *temp = new Node; temp->key = key; ...

Expression

An Expression is a combination of operators, constants and variables arranged as per rules of language. It may also include function calls which return values. An expression may consist of one or more operators and zero or more operator to produc...

Managing Data files

Hello Readers! As we all know a file is a collection of information which is stored on computer's disk and information can be saved to files and then later reused. But, what is the use of file handling why it is required?? Well, let's tak...

Memory management operators

C uses malloc() and calloc() function to allocate memory dynamically at runtime. Similarly it uses the function free() to free dynamically allocated memory. New operator can be used to create objects of any type.It takes the following general ...

To Implement two stacks in an array in C++?

To Implement two stacks in an array #include<iostream> #include<stdlib.h> using namespace std; class twoStacks { int *a; int size; int top1, top2; //top of two stacks public: twoStacks(int n) //...

Reverse an array without affecting special characters?

Program to Reverse an array without affecting special characters in C++ using namespace std; bool isAlphabet(char x) // Function returns true if an alphabet { return ( (x >= 'A' && x <= 'Z') || (x >= '...

Early binding and Late binding

In C++ program the compiler converts every statement in machine language of one or more lines, during compiled time. Every line is provided with the unique address. So each function of the program is provided with the unique machine language addr...

How to reverse a number without using % operator?

#include<string.h> int main() { int number1, number2; char str[10]; printf("\nEnter a Number:::"); scanf("%d", &number1); sprintf(str, "%d", number1);//step 1 strrev(str);//step 2 number2 = atoi(str);/...

Difference between delete and free() in C++?

free() function and delete operator are used to deallocate the memory a pointer is holding. free() function is used when the memory is allocated to the pointer by either malloc(),calloc() or realloc() function, whereas delete operator is used wh...

variable in c++

In c++ we use variables to store the value of a number. The type of the value is needed to be declared first because according to that it will allocate the memory to particular variable. Every variable is assigned with the unique memory address....

Comparison of Exception Handling in C++ and Java

Comparison of Exception Handling in C++ and Java In C++ and Java, keywords like try,catch and throw for exception handling are same,their meaning is also same but exception handling in C++ and Java differ in many ways. 1)In Java only instan...

Can function main() be overloaded in C++?

Can function main() be overloaded in C++? The main() function can be overloaded in C++ by defining main as member function of a class.Since main is not a reserved word in many programming languages like C++,C# ,java etc, main can be declared ...

Generating all possible permutation of a given range

If you want to generate permutation of the elements in a range in lexicographic order, then next_permutation function defined in STL algorithm might be helpful for you. Default template for next_permutation template <class InputIterator&...

Random shuffle in C++

Random shuffle function is used to randomly rearrange the elements in a given range. The random_shuffle function is defined in the STL algorithm. Template for random_shuffle template <class InputIterator> void random_shuffle (Input...

Reverse in C++

If you want to reverse the order of elements in a given range, then you can use the reverse function defined in the STL algorithm. Template for reverse template <class BidirectionalIterator> void reverse (BidirectionalIterator firs...

Count function in C++

If you want to count the presence of a element in a given range, then you can use the count() function defined in the STL algorithm. It returns the number of variable inside a range whose value is equal to the given number. Template for count...

Binary search in C++

If you want to find the presence of a element in a given sorted range, then you can use the binary_search function defined in the STL algorithm. The range should be sorted in ascending order to perform binary search. It returns true if el...

Multiplication of integer values using shift operator (Binary multiplication)

There is an interesting way to multiply two positive integer values without using " * " operator and using binary shift operator. The complexity of the program will depends on the number of bits in the binary representation of the multiplier val...

Sort function in C++

Sort function is used to sort a given range in ascending order. This function is defined in the header algorithm. There are two version are defined of it. template< class RandomIt > void sort( RandomIt first, RandomIt last ); templa...

Difference between pure virtual function and virtual function in C++

td p { margin-bottom: 0cm; }p { margin-bottom: 0.25cm; line-height: 120%; } Pure virtual function virtua...

Pure virtual function in C++

In C++, Pure virtual method or pure virtual function is a virtual function in which virtual function does not contain a definition inside the function declaration. A pure virtual function/method is declared by assigning a function equal to 0 in d...

Unwinding Stack in C++

Unwinding Stack in C++ Stacks are Last in First Out(LIFO) data structures i.e item last inserted is the first one to be out. C++ perform function calls using stack data structure.The function Call Stack is used for function call/return mechan...

Structures in C++

Structures in C++ is a collection of dissimilar data types .Structures is denoted by struct keyword .In structures we can access different data in a single block.It is usually used to keep the track of different kinds of records in a single block...

Friend Class in C++

Friend class in C++ Friend class Protected and private members of a class cannot be accessed from outside the class in which they are declared. A friend class can access these members of another class in which it is declared as friend.Frien...

Multiple Inheritance in C++

C++ supports multiple inheritance unlike java. In multiple inheritance a class in C++ can have more than one class as it's parent class i.e., it can inherit property from more than one class. class Area class Perimeter ...

Inheritance

In c++ inheritance is used in a concept of re-usability of code.In Inheritance there is a super/base class and sub/derived class. The base class act as a parent of the derived class. The derived class can inherit the properties of the base class....

Friend Function

Friend Function These are special functions which can access the private members of a class. Private and protected data of class can be accessed from a friend function. Declaration of Friend Function class className { .........

Input Output

The C++ standard libraries furnish a substantial wind up of input/output. C++ I/O occurs in streams, which are lineups of data. If data flow from a device like a keyboard to main memory is called input operation and if data flow back from main m...

Use of none_of function in C++

none_of function is used to test condition on the elements in a range[first,last), it will return true if the test condition is false for all of the element in the range or if the range is empty, else it will return false. To use this function w...

Merge Sort Algorithm

Merge sort is a sorting algorithm that uses "Divide and Conquer" method to sort the array.It divides the array into two halves and then recursively sort the two sub-array and then merge the two sorted sub-arrays into sequence. Time complexity ...

Overloading vs Overridding

Overloading : Same function name with different parameters/signatures. It is compile time polymorphism. It occurs in a same class methods. It is a static/compile time binding. For e.g: int sample() { cout<<"no argu...
prev 1
Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: