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
Articles on Trending Technologies
Technical articles with clear explanations and examples
Implicit return type int in C
In C, if a function is declared without an explicit return type, the compiler implicitly assumes the return type to be int. This behavior was allowed in older C standards (C89/C90) but is deprecated and not recommended. The C99 standard requires explicit return types for all functions. Syntax function_name(parameters) { /* Function body */ return value; /* Implicitly returns int */ } Example: Implicit Return Type Here's an example demonstrating implicit return type behavior − #include my_function(int x) { ...
Read MorePHP Program to check for Anagram
PHP (Hypertext Preprocessor) is a widely used server-side scripting language for web development. In PHP, you can check if two strings are anagrams by comparing their character frequencies using built-in functions. What is an Anagram? Anagrams are words or phrases formed by rearranging the letters of another word or phrase. In an anagram, all the original letters must be used exactly once, with no additional or missing letters. For example, "listen" and "silent" are anagrams because they use the same letters rearranged in different order. Using count_chars() Function The count_chars() function is a built-in PHP ...
Read MoreDifference between char s[] and char *s in C
In C programming, there are two common ways to declare strings: char s[] and char *s. While both can hold strings, they have fundamental differences in memory allocation, mutability, and behavior. Syntax char s[] = "string literal"; // Array declaration char *s = "string literal"; // Pointer declaration Key Differences Aspect char s[] char *s Type Array of characters Pointer to char Memory Location Stack (local array) Pointer on stack, string in read-only section Mutability Modifiable Read-only ...
Read MorePHP Program for Subset Sum Problem
The Subset Sum Problem is a classic problem in computer science and dynamic programming. Given a set of positive integers and a target sum, the task is to determine whether there exists a subset of the given set whose elements add up to the target sum. Using Recursive Solution The recursive approach explores all possible combinations by either including or excluding each element ? Found a subset with the given sum No subset with the given sum. In this example, the set is [1, 7, 4, 9, 2]. For sum ...
Read MoreVariable length arguments for Macros in C
In C, we can use variable length arguments for macros, similar to how we use them with functions. This is achieved using ellipsis (…) and the special __VA_ARGS__ identifier. The concatenation operator ## is used to handle cases where no variable arguments are provided. Syntax #define MACRO_NAME(fixed_params, ...) macro_body __VA_ARGS__ Where __VA_ARGS__ represents all the variable arguments passed to the macro, and ## can be used for token pasting. Example: Logging Macro with Variable Arguments This example demonstrates a logging macro that accepts variable arguments like printf(). The macro prints the filename, line ...
Read MorePHP Program for Rabin-Karp Algorithm for Pattern Searching
The Rabin-Karp algorithm is a string pattern matching algorithm that efficiently searches for occurrences of a pattern within a larger text. It was developed by Michael O. Rabin and Richard M. Karp in 1987. The algorithm utilizes a hashing technique to compare the hash values of the pattern and substrings of the text. It works as follows: Calculate the hash value of the pattern and the first window of the text. Slide the pattern over the text one position at a time and compare the hash values. If ...
Read MoreDifference between "int main()" and "int main(void)" in C/C++?
In C programming, you might notice two different ways to declare the main function: int main() and int main(void). While both are valid, there is a subtle but important difference in how C treats them. Syntax int main() int main(void) Key Difference In C, int main() means the function can accept any number of arguments, while int main(void) explicitly specifies that the function takes no arguments. In C++, both forms are equivalent and mean "no arguments". Example 1: Function Without void When a function is declared without void, C allows it to ...
Read MorePHP 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 More