Nishtha Thakur

Nishtha Thakur

398 Articles Published

Articles by Nishtha Thakur

Page 5 of 40

How to scale down an image with CSS to make it responsive

Nishtha Thakur
Nishtha Thakur
Updated on 15-Mar-2026 476 Views

The CSS max-width and height properties can be used to make images responsive, allowing them to scale down automatically based on the container size while maintaining their aspect ratio. Syntax img { max-width: 100%; height: auto; } Key Properties PropertyValueDescription max-width100%Ensures image never exceeds container width heightautoMaintains aspect ratio automatically Example: Basic Responsive Image The following example demonstrates how to make an image scale down responsively − .container { ...

Read More

Set top tooltip with CSS

Nishtha Thakur
Nishtha Thakur
Updated on 15-Mar-2026 223 Views

To set a top tooltip with CSS, you position the tooltip above the element using the bottom property along with position: absolute. The tooltip appears above the trigger element when hovered. Syntax .tooltip .tooltip-text { position: absolute; bottom: 100%; visibility: hidden; } .tooltip:hover .tooltip-text { visibility: visible; } Example The following example creates a tooltip that appears at the top when you hover over the text − ...

Read More

CSS animation-duration property

Nishtha Thakur
Nishtha Thakur
Updated on 15-Mar-2026 115 Views

The CSS animation-duration property specifies how long an animation should take to complete one full cycle. This property controls the speed of your animations by setting the time duration. Syntax selector { animation-duration: time; } Possible Values ValueDescription timeSpecifies the duration in seconds (s) or milliseconds (ms) 0sDefault value. No animation occurs Example: 2-Second Animation Duration The following example creates a moving and color-changing animation that completes in 2 seconds − div { ...

Read More

Style select options with CSS

Nishtha Thakur
Nishtha Thakur
Updated on 15-Mar-2026 2K+ Views

The CSS select element can be styled to enhance its appearance and user experience. You can modify properties like width, padding, borders, background colors, and more to customize the dropdown menu. Syntax select { property: value; } Example: Styling Select Element The following example demonstrates how to style a select dropdown with custom padding, borders, and background color − select { width: 100%; padding: ...

Read More

How to create a modal popup using JavaScript and CSS?

Nishtha Thakur
Nishtha Thakur
Updated on 15-Mar-2026 663 Views

Creating a modal popup means adding a dialog box, which generates on click of a button and closes when the user clicks anywhere outside of the popup or on the close button. × Modal Header This is the modal content. Click outside or on × ...

Read More

Why do we check for a NULL pointer before deleting in C/C++?

Nishtha Thakur
Nishtha Thakur
Updated on 15-Mar-2026 580 Views

In C programming, checking for a NULL pointer before calling free() is often seen in code, but it's technically unnecessary. The free() function is designed to safely handle NULL pointers by doing nothing when passed a NULL value. Syntax void free(void *ptr); Why NULL Check is Unnecessary According to the C standard, free(NULL) is guaranteed to be a no-op (no operation). This means the following code is redundant − #include #include int main() { int *ptr = NULL; ...

Read More

The best way to check if a file exists using standard C/C++

Nishtha Thakur
Nishtha Thakur
Updated on 15-Mar-2026 18K+ Views

In C programming, checking if a file exists is a common task that can be accomplished by attempting to open the file for reading. If the file opens successfully, it exists; otherwise, it doesn't exist. Syntax FILE *fopen(const char *filename, const char *mode); Method 1: Using fopen() Function The most straightforward approach is to use fopen() to attempt opening the file in read mode − #include int main() { FILE *file; /* Try to open file for ...

Read More

C program that won't compile in C++

Nishtha Thakur
Nishtha Thakur
Updated on 15-Mar-2026 567 Views

C++ is largely based on C, but it enforces stricter type checking and syntax rules. While most C programs compile in C++, some valid C code will not compile in C++ due to these stricter rules. Understanding these differences helps in writing portable code. Syntax There is no specific syntax for this concept, but rather a collection of C language features that C++ treats differently or rejects entirely. Example 1: Function Declaration Requirements In C, functions can be called before declaration (with implicit declaration), but C++ requires explicit declaration − #include int ...

Read More

Name Mangling and extern "C" in C++

Nishtha Thakur
Nishtha Thakur
Updated on 15-Mar-2026 1K+ Views

In C++, function overloading allows multiple functions with the same name but different parameter types or numbers. However, this creates a problem: how does the compiler distinguish between these functions in the object code? The solution is a technique called name mangling. Syntax extern "C" { // C function declarations } What is Name Mangling? Name mangling is a technique where the compiler modifies function names by adding information about parameters to create unique identifiers. C++ has no standardized name mangling scheme, so different compilers use different approaches. Example: ...

Read More

Program for Christmas Tree in C

Nishtha Thakur
Nishtha Thakur
Updated on 15-Mar-2026 1K+ Views

In C programming, creating a Christmas tree pattern involves printing pyramids of various sizes stacked one beneath another. This creates a festive tree-like structure with decorative characters that can simulate twinkling lights through randomization. Syntax void tree_triangle(int start, int end, int total_height); void display_tree(int height); void display_log(int height); Example: Static Christmas Tree Let's start with a basic Christmas tree that displays once − #include #include #include void display_random_leaf() { char type_of_leaves[5] = { '.', '*', '+', 'o', 'O' }; int ...

Read More
Showing 41–50 of 398 articles
« Prev 1 3 4 5 6 7 40 Next »
Advertisements