George John

George John

789 Articles Published

Articles by George John

Page 25 of 79

C Program to print hollow pyramid and diamond pattern

George John
George John
Updated on 15-Mar-2026 4K+ Views

In this tutorial, we will learn how to create hollow pyramid and diamond patterns in C programming. Unlike solid patterns, hollow patterns print stars only at the borders while keeping the interior empty using spaces. Syntax /* Hollow Pyramid Logic */ for(i = 1; i

Read More

C program to print characters without using format specifiers

George John
George John
Updated on 15-Mar-2026 880 Views

In this article we will see how we can print some characters without using any kind of format specifiers. The format specifiers in C are %d, %f, %c etc. These are used to print characters and numbers in C using the printf() function. Here we will see another way to print characters without using %c format specifier. This can be done by putting ASCII values directly in hexadecimal form using escape sequences. Syntax printf("\xHH"); // HH is hexadecimal ASCII value Method 1: Using Hexadecimal Escape Sequences The \x escape sequence allows us ...

Read More

How to pass a 2D array as a parameter in C?

George John
George John
Updated on 15-Mar-2026 1K+ Views

In C programming, a 2D array can be passed as a parameter to a function in several ways. The method depends on whether the array dimensions are known at compile time or need to be determined at runtime. Syntax // Method 1: Fixed dimensions (known at compile time) void function_name(int arr[ROWS][COLS]); // Method 2: Variable dimensions (C99 and later) void function_name(int rows, int cols, int arr[rows][cols]); // Method 3: Using pointer to array void function_name(int (*arr)[COLS]); Method 1: Using Fixed Dimensions When array dimensions are known at compile time, you can specify ...

Read More

When do function-level static variables get initialized in C/C++?

George John
George John
Updated on 15-Mar-2026 962 Views

Static variables can be defined using the static keyword. They are variables that remain in memory while the program is running, meaning their lifetime is the entire program execution. This is different from automatic variables, which remain in memory only when their function is running and are destroyed when the function exits. Function-level static variables are initialized only once − the first time the function is called. The memory for them is allocated at program load time, but the initialization occurs during the first function execution. Syntax static data_type variable_name = initial_value; Example: Static ...

Read More

How do I find the length of an array in C/C++?

George John
George John
Updated on 15-Mar-2026 22K+ Views

To find the length of an array in C, we can use various approaches that are essential for array manipulation. Finding the length of an array is a fundamental task used in looping through arrays, sorting, searching, and memory management operations. In this article, we will explore different methods to determine the size of an array in C programming. Syntax // Method 1: Using sizeof operator int length = sizeof(array) / sizeof(array[0]); // Method 2: Using pointer arithmetic int length = *(&array + 1) - array; Method 1: Using sizeof() Operator The ...

Read More

imagecolortransparent() function in PHP

George John
George John
Updated on 15-Mar-2026 365 Views

The imagecolortransparent() function in PHP sets a specific color in an image to be transparent. This is particularly useful when creating images with transparent backgrounds or when overlaying images. Syntax imagecolortransparent(resource $image [, int $color]) Parameters image − An image resource created by functions like imagecreatetruecolor() or imagecreate(). color (optional) − Color identifier created with imagecolorallocate(). If not specified, returns the current transparent color. Return Value The function returns the identifier of the new transparent color when a color is set. If no color parameter is provided, it returns the ...

Read More

imagecolorsforindex() function in PHP

George John
George John
Updated on 15-Mar-2026 134 Views

The imagecolorsforindex() function in PHP retrieves the RGBA color values for a specific color index in an image. This is useful when you need to analyze or manipulate colors at specific positions in an image. Syntax imagecolorsforindex(resource $image, int $index) Parameters image − An image resource created by image creation functions like imagecreate() or imagecreatefrompng() index − The color index value obtained from functions like imagecolorat() Return Value Returns an associative array containing four keys: red, green, blue, and alpha with their corresponding integer values (0-255 for RGB, 0-127 for ...

Read More

imagecolorclosest() function in PHP

George John
George John
Updated on 15-Mar-2026 138 Views

The imagecolorclosest() function gets the index of the closest color to the specified color in an image's palette. This function is particularly useful when working with palette-based images where you need to find the best match for a specific RGB color. Syntax imagecolorclosest(image, red, green, blue) Parameters image − Image resource created with image creation functions red − Red color component (0-255) green − Green color component (0-255) blue − Blue color component (0-255) Return Value The imagecolorclosest() function returns the index of the closest color in the palette of ...

Read More

imagecolorclosesthwb() function in PHP

George John
George John
Updated on 15-Mar-2026 94 Views

The imagecolorclosesthwb() function finds the index of the color that most closely matches a given RGB color using the HWB (Hue, Whiteness, Blackness) color model. This function is useful for color matching in palette−based images. Syntax imagecolorclosesthwb($image, $red, $green, $blue) Parameters $image − An image resource created by image creation functions like imagecreate() or imagecreatefromgif() $red − Red color component value (0−255) $green − Green color component value (0−255) $blue − Blue color component value (0−255) Return Value Returns an integer representing the index of the color in the image ...

Read More

imageflip() function in PHP

George John
George John
Updated on 15-Mar-2026 349 Views

The imageflip() function is used to flip an image using a given mode. This function modifies the image resource directly and is commonly used for creating mirror effects or rotating images. Syntax bool imageflip(resource $image, int $mode) Parameters $image − An image resource created using functions like imagecreatetruecolor(), imagecreatefrompng(), etc. $mode − The flip mode constant. Possible values are: IMG_FLIP_HORIZONTAL − Flips the image horizontally (left to right) IMG_FLIP_VERTICAL − Flips the image vertically (top to bottom) IMG_FLIP_BOTH − Flips the image both horizontally and vertically Return Value ...

Read More
Showing 241–250 of 789 articles
« Prev 1 23 24 25 26 27 79 Next »
Advertisements