Programming Articles - Page 1101 of 3363

Implementation of DFS using C language

Bhanu Priya
Updated on 21-Jan-2025 10:59:37

8K+ Views

Depth First Search (DFS) is an algorithm that traverses a graph, visiting all nodes before backtracking. It can also determine whether a path exists between two nodes. DFS begins at the root node and explores as far as possible along each branch before backtracking. DFS searches a graph or tree in a depth-wise manner. Algorithm Given below is an algorithm for the implementation of the Depth First Search (DFS) − Step 1 − Initially stack is empty. ... Read More

What is strtok_r() function in C language?

Bhanu Priya
Updated on 25-Jun-2024 23:21:10

4K+ Views

strtok_r() function in C language The strtok_r() function is similar to the strtok() function. The only key difference is that the _r, which is called as re-entrant function. A re-entrant function is a function which can be interrupted during its execution. This type of function can be used to resume execution. Because of this fact, re-entrant functions are thread-safe, means they can safely be interrupted by threads without any harm. strtok_r() function has an extra parameter called the context. so that function can resume at the right place. Syntax The syntax for strtok_r() function is as follows: // ... Read More

What is strtok() function in C language?

Bhanu Priya
Updated on 03-Sep-2021 06:33:30

979 Views

strtok() function is a part of the header file #include The syntax of strtok() function is as follows −char* strtok(char* string, const char* limiter);Input string string and a delimiter character limiter. strtok() will divide the string into tokens based on the delimited character.We can expect a list of strings from strtok(). But, the function returns a single string because after calling strtok(input, limiter), it will returns the first token.But we have to keep calling the function again and again on a NULL input string, until we get NULL! Generally, we used to keep calling strtok(NULL, delim) until it returns ... Read More

What is C Operator Precedence and Associativity?

Bhanu Priya
Updated on 03-Sep-2021 06:32:27

3K+ Views

First, let us understand what is operator precedence in C programming language.Operator PrecedenceOperator precedence is used to evaluate the order of operators evaluated in an expression. In C programming, every operator has a priority. When there is more than one operator in the given expression, the operator with higher precedence or priority is evaluated first and the operator with the least priority is evaluated later.Operator AssociativityOperator associativity is used to evaluate the order of operators with equal precedence in an expression. In the C programming language, when an expression contains multiple operators with equal or same precedence, we use associativity ... Read More

What is program development cycle in C language?

Bhanu Priya
Updated on 03-Sep-2021 06:27:49

27K+ Views

When we want to develop a program by using any programming language, we have to follow a sequence of steps. These steps are called phases in program development.The program development life cycle is a set of steps or phases which are used to develop a program in any programming language.Phases of program developmentProgram development life cycle contains 6 phases, which are as follows −Problem Definition.Problem Analysis.Algorithm Development.Coding & Documentation.Testing & Debugging.Maintenance.These six phases are depicted in the diagram given below −Problem DefinitionHere, we define the problem statement and decide the boundaries of the problem.In this phase, we need to understand ... Read More

Differentiate between int main and int main(void) function in C

Sindhura Repala
Updated on 20-Dec-2024 12:22:22

16K+ Views

The int main Function The int main function indicates that the program returns an integer value, typically 0, at the end of its execution. A return value of 0 signifies that the program has been executed successfully. The syntax of int main is as follows − int main(){  ---  ---  return 0; } Example Below is a C program for the int main() function without arguments. It uses recursion to decrement a static variable a from 10 to 0, printing its value after each decrement. The main function calls itself until a reaches 0, then returns 0. #include ... Read More

What are string searching functions in C language?

Sindhura Repala
Updated on 24-Jan-2025 13:08:11

2K+ Views

String Searching Functions The C string functions are built-in functions used for various operations and manipulations on strings. These functions perform tasks such as copying, comparing, concatenation, and determining the length of strings. The library also provides several string-searching functions, which are included as follows − Function Description ... Read More

What are memory operations in C language?

Bhanu Priya
Updated on 20-Jun-2024 00:33:01

1K+ Views

The library #include contains the basic memory operations. Although not strictly string functions, the functions are prototyped in #include . These memory operations are as follows − void *memchr (void *s, int c, size_t n); Search for a character in a buffer. int memcmp (void *s1, void *s2, size_t n); Compare two buffers. ... Read More

What is conditional compilation in C language?

Sindhura Repala
Updated on 18-Dec-2024 17:18:13

14K+ Views

In C programming language, several directives control the selective compilation of different parts of the program code. Conditional Compilation is a set of preprocessing directives that allows us to exclude and include parts of a program based on specified conditions. Each directive in the compilation is processed across different platforms, including debug and release versions. They are as follows − #if #else #elif #endif The "#if" Directory The #if is a directive preprocessor that evaluates the expression or condition. If the condition ... Read More

Differentiate between array and structures in C

Bhanu Priya
Updated on 02-Sep-2021 13:17:30

393 Views

The major differences between an array and a structure in C programming language are as follows −ArraysStructuresAn array is a single entity representing a collection of data items of same data types.A structure is a single entity representing a collection of data items of different data types.Individual entries in an array are called elements.Individual entries in a structure are called members.An array declaration reserves enough memory space for its elements.The structure definition reserves enough memory space for its members.There is no keyword to represent arrays but the square braces [] preceding the variable name tells us that we are dealing ... Read More

Advertisements