Found 33676 Articles for Programming

C++ Program to Implement Stack Using Two Queues

Aman Kumar
Updated on 16-May-2025 17:12:01

1K+ Views

Queue The queue is a linear data structure that follows the First-In-First-Out (FIFO) operation. Where insertions are done at one end (rear) and deletions are done from another end (front). The first element that is entered is deleted first. Following are the stack operations: EnQueue (int data): Insertion at rear end int DeQueue(): Deletion from front end Stack The stack is also a linear data structure that follows the Last-In-First-Out (LIFO) operation. Where the element will be added and removed from the top. Following are the stack operations: ... Read More

cout << endl vs cout << \\"\\" in C++

Aman Kumar
Updated on 20-May-2025 18:50:02

1K+ Views

In C++, both count

C++ Program to Implement Queue Using Two Stacks

Aman Kumar
Updated on 21-May-2025 14:27:32

2K+ Views

Stack The stack is a linear data structure that follows the Last-In-First-Out (LIFO) operation. Where the element will be added and removed from the top. Following are the stack operations: push (int data): Insertion at top int pop(): Deletion from top Queue The queue is also a linear data structure that follows the First-In-First-Out (FIFO) operation. Where insertions are done at one end (rear) and deletions are done from another end (front). The first element that is entered is deleted first. Following are the stack operations: EnQueue (int data): Insertion at rear end int DeQueue(): Deletion from ... Read More

C++ Program to Implement the String Search Algorithm for Short Text Sizes

Aman Kumar
Updated on 20-May-2025 18:50:55

451 Views

Searching for a substring within a short text is a common operation in many C++ programs, like as small-scale text editors, command line utilities, and education projects. So, in this article, we will implement a string search algorithm for short text sizes. Importance of String Search String search algorithms find a substring within another string. While advanced methods like KMP and Boyer-Moore are great for longer texts, a simple method like Naive search works well for short texts without added complexity. Algorithm to Implement String Search Algorithm for Short Text Sizes The Following is a string search algorithm − Begin ... Read More

C++ Program to Implement Bitap Algorithm for String Matching

Aman Kumar
Updated on 20-May-2025 19:24:35

493 Views

The bitap algorithm is fuzzy string matching algorithm that is used to find approximate matches between a pattern and a text. The algorithm determines whether a given text contains a substring that is "approximately equal" to a given pattern, where approximate equality is defined in terms of Levenshtein distance (or number of edits) if the substring and pattern are within a given distance k of each other, then according to the algorithm they are equal. It begins by precomputing a set of bitmasks containing one bit for each element of the pattern. So we can do most of the work with ... Read More

Octal literals in C

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

5K+ Views

In C/C++ we can use octal literals by typing a zero before the actual number. For example, if an octal number is 25, then we have to write 025.Example Code#include int main() {    int a = 025;    int b = 063;    printf("Decimal of 25(Octal) is %d", a);    printf("Decimal of 63(Octal) is %d", b); }OutputDecimal of 25(Octal) is 21 Decimal of 63(Octal) is 51

Can a C++ virtual functions have default parameters?

Aman Kumar
Updated on 20-May-2025 19:29:14

827 Views

Yes, C++ virtual functions can have default parameters. The default parameter is the value provided during function declaration, such that the value can be automatically assigned if no argument is passed to them. In case any value is passed the default value is overridden and becomes a parameterized argument. Virtual Function A virtual function is a member function declared in a base class and can be overridden in a derived class. When we use a pointer or reference to the base class to refer to an object of the derived class, you can call a virtual function for that object. ... Read More

SQL using C/C++ and SQLite

Nitya Raut
Updated on 30-Jul-2019 22:30:25

2K+ Views

In this section, you will learn how to use SQLite in C/C++ programs.InstallationBefore you start using SQLite in our C/C++ programs, you need to make sure that you have SQLite library set up on the machine. You can check SQLite Installation chapter to understand the installation process.C/C++ Interface APIsFollowing are important C/C++ SQLite interface routines, which can suffice your requirement to work with SQLite database from your C/C++ program. If you are looking for a more sophisticated application, then you can look into SQLite official documentation.Serial NoAPI & Description1sqlite3_open(const char *filename, sqlite3 **ppDb)This routine opens a connection to an SQLite ... Read More

Calling virtual functions inside constructors in C++

Smita Kapse
Updated on 30-Jul-2019 22:30:25

291 Views

Virtual functions calling from a constructor or destructor is dangerous and should be avoided whenever possible as the virtual function we call is called from the Base class and not from the derived class.The reason is that in C++ Super-classes are constructed before derived classes. So, in the following example, as B must be instantiated, before D is instantiated. When B's constructor is called, it's not D yet, so the virtual function table still has the entry for B's copy of s().Example Code Live Demo#include using namespace std; class B {    public: B() {       s();    } ... Read More

How to execute zombie and orphan process in a single C program?

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

2K+ Views

In this section we will see how to execute zombie process and orphan process in a single program in C/C++. Before going to the main discussion, let us see what are the zombie process and orphan process.Zombie ProcessesA zombie process is a process whose execution is completed but it still has an entry in the process table. Zombie processes usually occur for child processes, as the parent process still needs to read its child’s exit status. Once this is done using the wait system call, the zombie process is eliminated from the process table. This is known as reaping the ... Read More

Advertisements