Server Side Programming Articles

Page 979 of 2109

PHP Program to find the Closest Pair from Two Sorted Arrays

Pradeep Kumar
Pradeep Kumar
Updated on 15-Mar-2026 214 Views

Given two sorted arrays and a number x, we need to find a pair (one element from each array) whose sum is closest to x. This is a classic two-pointer problem that can be solved efficiently. Problem Statement Find a pair from two sorted arrays such that the sum of the pair is closest to a given target value x. Input: ar1 = [1, 3, 5, 7, 9]; ar2 = [2, 4, 6, 8, 10]; x = 12; Output: The closest pair is [1, 10] because 1+10=11 which is closest to 12 ...

Read More

Interesting Facts about C Programming

Smita Kapse
Smita Kapse
Updated on 15-Mar-2026 510 Views

C programming language has several interesting and lesser-known features that can surprise even experienced programmers. Here are some fascinating facts about C that demonstrate its flexibility and unique behaviors. Fact 1: Switch Case Labels Inside If-Else Case labels in a switch statement can be placed inside if-else blocks due to the way switch works with jump labels − #include int main() { int x = 2, y = 2; switch(x) { case 1: ...

Read More

PHP program to Fetch Data from Localhost Server Database using XAMPP

Pradeep Kumar
Pradeep Kumar
Updated on 15-Mar-2026 1K+ Views

To fetch data from a localhost server database using XAMPP, you need to set up a local web server environment and create a PHP script that connects to your MySQL database. This tutorial will guide you through the complete process. Prerequisites: Install XAMPP from https://www.apachefriends.org/download.html before proceeding. Setting Up XAMPP Server Step 1: Start the XAMPP Server Launch the XAMPP control panel Start the Apache and MySQL services by clicking "Start" next to each service Step 2: Access phpMyAdmin ...

Read More

Use of bool in C

Samual Sam
Samual Sam
Updated on 15-Mar-2026 2K+ Views

In C, there is no predefined datatype as bool. However, we can create a boolean type using enum or use the standard header (C99 and later). With enum, we create a boolean type where false holds value 0 and true holds value 1. Syntax typedef enum { false, true } bool; // Or using C99 standard #include Method 1: Using Enum We can create a custom boolean type using typedef enum − #include typedef enum { false, true } bool; int main() { ...

Read More

PHP Program to Count Trailing Zeroes in Factorial of a Number

Pradeep Kumar
Pradeep Kumar
Updated on 15-Mar-2026 361 Views

The factorial of a non-negative integer, denoted by the symbol "!", is the product of all positive integers less than or equal to that number. In other words, the factorial of a number is obtained by multiplying that number by all the positive integers below it. For example, the factorial of 5 is calculated as: 5! = 5 x 4 x 3 x 2 x 1 = 120 Similarly, the factorial of 0 is defined to be 1: 0! = 1 What are Trailing Zeroes? In the factorial of a number, trailing zeroes refer ...

Read More

How to write a running C code without main()?

Samual Sam
Samual Sam
Updated on 15-Mar-2026 8K+ Views

In C programming, it is possible to write a program without the traditional main() function. While main() appears to be the entry point from a programmer's perspective, the system actually calls _start() first, which sets up the environment before calling main(). Syntax int _start() { // Program code here _exit(status_code); } Note: To compile programs without main(), use the -nostartfiles flag with gcc to skip the standard startup files that expect a main() function. Example Here's how to create a C program using ...

Read More

Print a long int in C using putchar() only

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 2K+ Views

Here we will see how to print long int value using the putchar() function in C. We can easily print the value of some variables using printf() in C, but here the restriction is, we cannot use any other function except putchar(). As we know that the putchar() is used to print only characters. We can use this function to print each digit of the number. When one numeric value is passed, we have to add character '0' with it to get the ASCII form. Syntax void print_long(long value); int putchar(int character); Example ...

Read More

PHP Program to Count set Bits in an Integer

Pradeep Kumar
Pradeep Kumar
Updated on 15-Mar-2026 456 Views

In PHP, counting set bits (1s) in an integer's binary representation is a common programming task. A set bit refers to a binary digit that has the value 1, while a clear bit has the value 0. For example, the number 12 in binary is 1100, which has 2 set bits. What is Binary Code? Binary code is a system of representing information using a base-2 numeral system. It uses only two digits, 0 and 1, to represent all values. Each digit in binary code is called a bit (short for binary digit). In binary code, each ...

Read More

How to count set bits in a floating point number in C?

Samual Sam
Samual Sam
Updated on 15-Mar-2026 592 Views

In this problem, one floating point value is given. We have to find the number of set bits in the binary representation of it. This involves analyzing the IEEE 754 single-precision floating point format used by C compilers. For example, if a floating point number is 0.15625, there are six set bits in its 32-bit binary representation. The IEEE 754 format consists of 1 sign bit, 8 exponent bits, and 23 mantissa bits. IEEE 754 Single Precision Format (32 bits) S ...

Read More

PHP Program to Count Page Views

Pradeep Kumar
Pradeep Kumar
Updated on 15-Mar-2026 4K+ Views

In PHP, counting page views is a common requirement for tracking user engagement and website analytics. This can be achieved using sessions to maintain a counter that persists across multiple page visits for each user session. What is Session? In PHP, a session is a way to store and persist data across multiple requests or page views for a specific user. When a user visits a website, a unique session ID is assigned to them, typically stored as a cookie on the user's browser. This session ID is used to associate subsequent requests from the same user with ...

Read More
Showing 9781–9790 of 21,090 articles
« Prev 1 977 978 979 980 981 2109 Next »
Advertisements