×
Home Discussions Write at Opengenus IQ
×
  • DSA Cheatsheet
  • HOME
  • Track your progress
  • Deep Learning (FREE)
  • Join our Internship 🎓
  • RANDOM
  • One Liner
Harshita Sahai

Harshita Sahai

Maintainer at OpenGenus | Previously Software Developer, Intern at OpenGenus (June to August 2019) | B.Tech in Information Technology from Guru Gobind Singh Indraprastha University (2017 to 2021)

South Delhi, India •
50 posts •
C++

Enumeration in C++

Enumeration (or enum) is a user defined data type in C and C++. It is mainly used to assign names to integral constants, the names make a program easy to read and maintain.

Harshita Sahai Harshita Sahai
C++

while loop in C++

while loop is a most basic loop in C++. while loop has one control condition, and executes as long the condition is true. The condition of the loop is tested before the body of the loop is executed, hence it is called an entry-controlled loop.

Harshita Sahai Harshita Sahai
C++

switch case in C++

A switch statement in C++ allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each case.

Harshita Sahai Harshita Sahai
Algorithms

Hamiltonian Path

Hamiltonian Path is a path in a directed or undirected graph that visits each vertex exactly once. The problem to check whether a graph (directed or undirected) contains a Hamiltonian Path is NP-complete, so is the problem of finding all the Hamiltonian Paths in a graph.

Harshita Sahai Harshita Sahai
C++

do while loop in C++

Do while loop in C++ is an exit controlled loop and hence, it executes at least once even when the test-expression is false initially. We illustrate the concept and usage in C with different examples

Harshita Sahai Harshita Sahai
C++

Builder Pattern in C++

Builder pattern in C++ aims to “Separate the construction of a complex object from its representation so that the same construction process can create different representations.” It is used to construct a complex object step by step and the final step will return the object.

Harshita Sahai Harshita Sahai
C++

Default arguments in C++

A default argument in C++ is a value provided in a function declaration that is automatically assigned by the compiler if the caller of the function doesn’t provide a value for the argument with a default value.

Harshita Sahai Harshita Sahai
C++

Iterators in C++ STL

Iterators in C++ Standard Template Library are used to point at the memory addresses of STL containers. They are primarily used in sequence of numbers, characters etc. They reduce the complexity and execution time of program.

Harshita Sahai Harshita Sahai
C++

if else statement in C++

If else statement in C++ are program control statements that are widely used. We explore it and its variants like if else if, nested if else and if statements.

Harshita Sahai Harshita Sahai
C++

Factory Pattern in C++

Factory method also known as a static class is a creational design pattern, i.e. it is related to object creation. In this we create object without exposing the creation logic to client and the client use the same common interface to create new type of object. Idea is to use a static member function

Harshita Sahai Harshita Sahai
C++

constructor in C++

A constructor is a member function of a class which initializes objects of a class. In C++, Constructor is automatically called when object(instance of class) is created it is considered to be a special member function of the class.

Harshita Sahai Harshita Sahai
C++

delete operator in C++

In C++, Delete is an operator that is used to destroy array and non-array(pointer) objects which are created by new operator as well as NULL pointers. Using operator overloading, we can delete user defined objects as well

Harshita Sahai Harshita Sahai
C++

new operator in C++

In C++, the new operator denotes a request for memory allocation on the Heap. If sufficient memory is available, new operator initializes the memory and returns the address of the newly allocated and initialized memory to the pointer variable.

Harshita Sahai Harshita Sahai
C++

Virtual Function in C++

A virtual function in C++ is a member function which is declared within a base class and is overriden by a derived class. When you refer to a derived class object using a pointer or a reference to the base class, you can call a virtual function for that object and execute the derived class function

Harshita Sahai Harshita Sahai
C++

Namespace in C++

Namespaces in C++ allow us to group named entities that otherwise would have global scope into narrower scopes, giving them namespace scope. This allows organizing the elements of programs into different logical scopes referred to by names.

Harshita Sahai Harshita Sahai
C++

Function Overriding in C++

Function overriding (compile time polymorphism) is a feature in C++ that allows us to have a function in child class which is already present in the parent class. A child class inherits the data members and member functions of parent class and to override functionality, function overriding is used

Harshita Sahai Harshita Sahai
C++

Function Overloading in C++

Function overloading is a feature in C++ where two or more functions can have the same name but different parameters. This is used in situations when a class B is inherits from class A and a particular behaviour of the class B needs to be modified.

Harshita Sahai Harshita Sahai
C++

for loop in C++

For loop has three components: initialization Statement, test Expression and update Statement. We have explored for loop in C++ and presented examples and compared it with while loop.

Harshita Sahai Harshita Sahai
Software Engineering

goto statement in C

The goto statement is a jump statement which is sometimes also referred to as unconditional jump statement. The goto statement can be used to jump from anywhere to anywhere within a function. The use of goto statement is highly discouraged and can be avoided using break and continue statements.

Harshita Sahai Harshita Sahai
Software Engineering

Break Statement in C

Break Statement is a loop control statement which is used to terminate the loop. As soon as the break statement is encountered from within a loop, the loop iterations stops there and control returns from the loop immediately to the first statement after the loop. break can be used in all loop

Harshita Sahai Harshita Sahai
Software Engineering

Functions in C

A function in C is a set of statements that take inputs, do some specific computation and produces output. The idea is to put some commonly or repeatedly done task together and make a function, so that instead of writing the same code again and again for different inputs, we can call the function.

Harshita Sahai Harshita Sahai
Software Engineering

An in-depth look into Recursion in C

Recursion is a coding technique/ design in which a function calls itself directly or indirectly and the corresponding function is called as recursive function. Using this many problems can be solved easily with less time. C, C++, Java, Python, Go and others support Recursion except Fortan 77

Harshita Sahai Harshita Sahai
Software Engineering

malloc vs calloc vs realloc

We take a deep look into the 3 dynamic memory allocation techniques in C/ C++ namely malloc, calloc and realloc and explore the difference. malloc stand for memory allocations, calloc for contiguous allocation and realloc for re-allocation.

Harshita Sahai Harshita Sahai
Software Engineering

for loop in C

Loop is a programming concept which is natively supported by C. Loops are used to repeat a particular coding task where each repetition follows a particular pattern which can be incorporated in a code. Example of such a task is printing integers from 1 to 10.

Harshita Sahai Harshita Sahai
Algorithms

Fibonacci Search

Fibonacci search is an efficient search algorithm based on divide and conquer principle using Fibonacci series that can find an element in the given sorted in O(log N) time complexity. It is better than Binary search as it is more cache friendly and uses only addition and subtraction operations.

Harshita Sahai Harshita Sahai
OpenGenus IQ © 2025 All rights reserved ™
Contact - Email: team@opengenus.org
Primary Address: JR Shinjuku Miraina Tower, Tokyo, Shinjuku 160-0022, JP
Office #2: Commercial Complex D4, Delhi, Delhi 110017, IN
Top Posts LinkedIn Twitter
Android App
Apply for Internship