Found 1452 Articles for C

C program to display numbers in reverse order using single linked list

Bhanu Priya
Updated on 03-Sep-2021 06:54:01

566 Views

Linked lists use dynamic memory allocation and are collection of nodes.Nodes have two parts which are data and link.Types of Linked ListsThe types of linked lists in C programming language are as follows −Single / Singly linked listsDouble / Doubly linked listsCircular single linked listCircular double linked listSingle linked listThe diagram given below depicts the representation of single linked list.ExampleFollowing is the C program to display the numbers in reverse order by using the single linked list − Live Demo#include #include struct node {    int num;    struct node *nextptr; }*stnode; void createNodeList(int n); void reverseDispList(); void displayList(); ... Read More

C program to find trailing zero in given factorial

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

3K+ Views

In order to find the trailing zero in a given factorial, let us consider three examples as explained below −Example 1Input − 4Output − 0Explanation − 4! = 24, no trailing zero.Factorial 4! = 4 x 3 x 2x 1 = 24. No trailing zero i.e. at 0’s place 4 number is there.Example 2Input − 6Output − 1Explanation − 6! = 720, one trailing zero.Factorial 6! = 6 x 5 x 4 x 3 x 2 x 1 = 720, one trailing zero, because at 0’s place 0 number is there.Example 3The input is as follows −n = 4 n ... Read More

C program to print Excel column titles based on given column number

Bhanu Priya
Updated on 03-Sep-2021 06:44:31

566 Views

ProblemA program to print Excel column title that corresponds to a given column number (integer value). User has to enter the integer number based on given number it has to print excel column number.SolutionThe solution to print Excel column title that corresponds to a given column number in C programming language is explained below −Example 1Let us see an example.1 -> A 2 -> B ... 26 -> Z 27 -> AA 28 -> AB ...Example 2The input is as follows −number = 3 number = 27 number = 151The output is as follows −Excel column title: C Excel column ... Read More

C program to represent numbers in numerator and denominator in string format

Bhanu Priya
Updated on 03-Sep-2021 06:42:09

841 Views

ProblemFind the fraction part from two given integers given by user at run time by using the dynamic memory allocation and represent the numerator and denominator in string format.SolutionThe solution to represent the numerator and denominator in string format is as follows −Example -The input is given below −Numerator1 = 3 Denominator2 = 2 numerator2 = 4 denominator2 = 7The output is as follows −Fractional part1: 1.5 Fractional part2: 0.(571428)ExampleFollowing is the C program to represent the numerator and denominator in string format −#include #include #include #include char* fractionToDecimal(int numerator, int denominator) {    char ... Read More

Implementation of DFS using C language

Bhanu Priya
Updated on 03-Sep-2021 06:38:42

4K+ Views

Depth First Search (DFS) is an algorithm which traverses a graph and visits all nodes before coming back it can determine. Also, it determines whether a path exist between two nodes.It searches a graph or tree in depth-wise manner.AlgorithmGiven below is an algorithm for the implementation of the Depth First Search (DFS) −Step 1 − Initially stack is empty.Step 2 − If a node to be visited is not present in the stack, then we push it onto the stack and mark it as visited.Step 3 − Then, check if the current node matches our search criteria or not.    ... Read More

What is strtok_r() function in C language?

Bhanu Priya
Updated on 03-Sep-2021 06:34:46

3K+ Views

This 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.The syntax for strtok_r() function is as follows:#include char *strtok_r(char *string, const char *limiter, char **context);ExampleFollowing is the C program for ... Read More

What is strtok() function in C language?

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

846 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

2K+ 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 are the C Tokens?

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

567 Views

The C program is a collection of instructions and each instruction is a collection of individual units.Every small individual unit of a C program is generally called as token and every instruction in a C program is a collection of tokens.Tokens are used to construct the C programs and they are also said to be the basic building blocks of a C program.In a C program, tokens contain the following −KeywordsIdentifiersOperatorsSpecial SymbolsConstantsStringsData valuesIn a C program, a collection of all these keywords, identifiers, operators, special symbols, constants, strings, and data values are called tokens.ExampleFollowing is the C program to print ... Read More

What is program development cycle in C language?

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

17K+ 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

Previous 1 ... 4 5 6 7 8 ... 146 Next
Advertisements