Aman Kumar

Aman Kumar

38 Articles Published

Articles by Aman Kumar

38 articles

Assertions in C/C++

Aman Kumar
Aman Kumar
Updated on 18-Jun-2025 626 Views

What is an Assertions in C/C++? An assertion is a statement used to test assumptions made by the program. When an assertion fails, the program displays an error and stops. This is mainly used for debugging. In C and C++, assertions are handled using the assert() macro defined in the (C) or (C++) header file. Following is the declaration for assert() Macro. #include // in C // or #include in C++ assert(expression); The parameter of this assert() is expression: This can be a variable or any C/C++ expression. If ...

Read More

Can a C++ virtual functions have default parameters?

Aman Kumar
Aman Kumar
Updated on 20-May-2025 927 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

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

Aman Kumar
Aman Kumar
Updated on 20-May-2025 524 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 find the median of two sorted arrays using binary search approach

Aman Kumar
Aman Kumar
Updated on 20-May-2025 323 Views

The median is defined as the middle value of a sorted list of numbers, and the middle value is found by ordering the numbers in ascending order. Once the numbers are ordered, the middle value is called the median of the given data set. Here, in this article, we have two different sorted arrays and need to find the median of these two array using binary search. Median depends on the sorted combined array. So, the following cases may occur: If the length of the combined array is odd, then the median should be the ...

Read More

C++ Program to Implement Stack Using Two Queues

Aman Kumar
Aman Kumar
Updated on 16-May-2025 2K+ 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

fork() to execute processes from bottom to up using wait() in C++

Aman Kumar
Aman Kumar
Updated on 15-May-2025 3K+ Views

The fork() system call is used to create a process commonly known as a child process if the fork() returns 0. Otherwise, the created process is known as the parent process. All processes created with fork() execute in parallel. But what if we want the last process to be executed first? In this case, the parent process would execute last because of bottom-to-top execution. This can be done using the wait() system call. The wait system call is used to process handling. It pauses the execution of the calling process until the child process has finished its execution. It's commonly ...

Read More

How to create a clickable dropdown menu with CSS and JavaScript?

Aman Kumar
Aman Kumar
Updated on 24-Sep-2024 15K+ Views

To create a clickable dropdown menu with CSS and JavaScript, it helps in adding more options, content or links in webpage while saving the space and not overcrowding the webpage. User should have basic knowldge of CSS and javascript to design and add interactivity to the dropdown menu. In this article, we are having a button and three links and our task is to create a clickable dropdown menu with CSS and JavaScript. Steps to Create a Clickable Dropdown Menu We will be following below mentioned steps to create a clickable dropdown menu with CSS and JavaScript: ...

Read More

How to hide a navigation menu on scroll down with CSS and JavaScript?

Aman Kumar
Aman Kumar
Updated on 19-Aug-2024 6K+ Views

To hide a navigation menu on scroll down with CSS and JavaScript, user should have basic knowledge of javascript conditional statement and CSS. We will be creating the navigation menu using HTML, style the navigation menu using CSS and use Javascript to hide navigation menu while scrolling down. We are having a navigation menu with textual content, our task is to hide the navigation menu while scrolling down. In this article, we will be implementing following steps to hide a navigation menu on scroll down with CSS and JavaScript: Creating Structure of Navigation Menu Using ...

Read More

How to create responsive Modal Images with CSS and JavaScript?

Aman Kumar
Aman Kumar
Updated on 19-Dec-2022 3K+ Views

A modal is a dialog box/popup window that is displayed on top of the current page. To create responsive modal images, we use JavaScript to trigger the modal and display the current image inside the when it is clicked on. Also, we are using alt for the image caption text inside the model. Responsive modal images are images that are enlarged to fit into the window based on their size, device resolution, orientation and page layout. These images are usually enlarged with a mouse click. They can also be downloaded on a click from the web browsers. In this example, ...

Read More

How to create a responsive slideshow with CSS and JavaScript?

Aman Kumar
Aman Kumar
Updated on 19-Dec-2022 3K+ Views

In this article, we are going to create a responsive slideshow with the help of JavaScript and CSS. A responsive slideshow or we can say a responsive image slider, or a responsive images slider with text is a visually attractive and interactive design element that take part your viewers on the website it will have from one or more images with a text overlay on it. That is, it will display a series of images with a text on them. This also provide two arrow buttons suing which you can browse through the images (in both diresctions). This is used ...

Read More
Showing 1–10 of 38 articles
« Prev 1 2 3 4 Next »
Advertisements