Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Server Side Programming Articles
Page 981 of 2109
PHP Program for Naive Algorithm for Pattern Searching
PHP (Hypertext Preprocessor) is a widely used server-side scripting language for web development. The Naive algorithm, also known as the Brute Force algorithm, is a simple pattern searching technique that finds occurrences of a pattern within a text by comparing characters one by one. What is Naive Algorithm? The Naive algorithm is called "naive" because it doesn't employ sophisticated data structures or advanced techniques. It works by iterating through the text and comparing each character with the corresponding character in the pattern. If a mismatch occurs, it moves to the next position in the text and starts the ...
Read MoreWhat is long long in C/C++?
In C programming, long long is an extended integer data type that provides a larger range for storing integer values than the standard long type. The long long type was introduced in C99 standard to handle very large integer values that exceed the capacity of regular int or long types. Syntax long long variable_name; long long int variable_name; // equivalent to above Size and Range The long long data type is guaranteed to be at least 64 bits (8 bytes) according to the C standard. The exact size may vary between systems, but it's ...
Read MoreCheck input character is alphabet, digit or special character in C
In this section, we will see how to check whether a given character is a number, alphabet, or special character in C. We can classify characters by checking their ASCII values against specific ranges. The alphabets are from A – Z and a – z, numbers are from 0 – 9, and all other characters are considered special characters. Syntax if((ch >= 'A' && ch = 'a' && ch = '0' && ch = 'A' && ch = 'a' && ch = '0' && ch
Read MorePHP Program for Minimum Number of Jumps to Reach End
This problem involves finding the minimum number of jumps required to reach the end of an array, where each element represents the maximum number of steps you can jump from that position. Method 1: Naive Recursive Approach The naive recursive approach explores all possible paths from each position and chooses the minimum number of jumps − Minimum number of jumps required to reach the end: 3 Method 2: Dynamic Programming Dynamic programming optimizes the solution by storing results of subproblems to avoid redundant calculations − ...
Read Morekbhit in C language
The kbhit() function in C checks if a key has been pressed on the keyboard without waiting for the Enter key. It returns a non-zero value if a key is available to be read, otherwise returns zero. However, kbhit() is non-standard and platform-specific (Windows/DOS only). Syntax int kbhit(void); Parameters None: The function takes no parameters. Return Value Returns a non-zero value if a key has been pressed. Returns zero if no key is pressed. Example Note: This example uses Windows-specific headers (conio.h) and will not ...
Read MorePHP Program for Median of two Sorted Arrays of Same Size
The median is a value that separates the higher half from the lower half of a data set. When finding the median of two sorted arrays of the same size, we need to merge them conceptually and find the middle elements. This can be done efficiently using a merge-based approach without actually creating a new merged array. Algorithm Approach The solution uses two pointers to traverse both arrays simultaneously, keeping track of the two middle elements needed to calculate the median. Since we have 2n total elements, the median will be the average of elements at positions n-1 ...
Read MoreC function argument and return values
In C programming, functions can be categorized based on two criteria: whether they accept arguments (parameters) and whether they return a value. This gives us four distinct types of functions that cover all possible combinations. Syntax return_type function_name(parameter_list) { // Function body return value; // Optional, depends on return_type } Types of Functions Function with no arguments and no return value − Takes no input and returns nothing (void) Function with no arguments but returns a value − Takes no input but returns a value ...
Read MorePHP Program for Largest Sum Contiguous Subarray
The Largest Sum Contiguous Subarray problem, also known as the Maximum Subarray Problem, involves finding a contiguous subarray within a given array that has the largest sum. This is a classic algorithmic problem that can be efficiently solved using Kadane's Algorithm. Array: [-2, 1, -3, 4, -1, 2, 1, -5, 4] -2 1 -3 ...
Read Moreabs(), labs(), llabs() functions in C/C++
The C standard library provides different functions to calculate the absolute value of integers based on their data types. The abs(), labs(), and llabs() functions handle int, long, and long long data types respectively, returning the non-negative value of their arguments. Syntax int abs(int n); long labs(long n); long long llabs(long long n); The abs() Function The abs() function returns the absolute value of an integer argument. It is defined in stdlib.h and works with int type data − Example #include #include int main() { ...
Read Moreldexp() function in C/C++
The ldexp() function in C computes the result of multiplying a floating-point number by an integral power of 2. It calculates x * 2^exp where x is a floating-point value and exp is an integer exponent. Syntax float ldexp(float x, int exp); double ldexp(double x, int exp); long double ldexp(long double x, int exp); Parameters x − The floating-point base value exp − The integer exponent representing power of 2 Return Value Returns x * 2^exp. If the result is too large to represent, it returns HUGE_VAL (infinity). Example ...
Read More