Recursion in C programming

Recursion is expressing an entity in terms of itself. In C programming, recursion is achieved using functions known as recursive function. Recursive functions are very powerful in solving and expressing complex mathematical problems.

Until now, we called a function from another function. However, C language allows a function to call itself known as Recursive function.

Read more

return statement in C

Quick links

A function is a collection of statements grouped together to do some specific task. It may return a value. However, in no case a function will return more than one value. What does it mean by returning a value and where it is returned? To understand this let us consider an example.

Read more

Function arguments in C – Call by value and Call by reference

Function arguments are the inputs passed to a function. A function must declare variables to accept passed arguments. A variable that accepts function argument is known as function parameter.

In programming function argument is commonly referred as actual parameter and function parameter is referred as formal parameter. I will be using these words interchangeably throughout this series of C programming tutorial.

Read more

Functions in C programming

A function is a collection of statements grouped together to do some specific task. In series of learning C programming, we already used many functions unknowingly. Functions such as – printf(), scanf(), sqrt(), pow() or the most important the main() function. Every C program has at least one function i.e. the main() function.

Read more

C program to swap two numbers using call by reference

Write a C program to swap two numbers using pointers and functions. How to swap two numbers using call by reference method. Logic to swap two number using pointers in C program.

Example

Input

Input num1: 10
Input num2: 20

Output

Values after swapping:
Num1 = 20
Num2 = 10

Read more

C program to remove spaces, blanks from a string

Write a C program to remove extra spaces, blanks from a string. How to remove extra blank spaces, blanks from a given string using functions in C programming. Logic to remove extra white space characters from a string in C.

Example

Input

Input string: Learn     C      programming at  Codeforwin.

Output

String after removing extra blanks: 
"Learn C programming at Codeforwin"

Read more

C program to replace all occurrences of a character in a string

Write a C program to replace all occurrence of a character with another in a string using function. How to replace all occurrences of a character with another in a string using functions in C programming. Logic to replace all occurrences of a character in given string.

Example

Input

Input string: I_love_learning_at_Codeforwin.
Input character to replace: _
Input character to replace with: -

Output

String after replacing '_' with '-': I-love-learning-at-Codeforwin

Read more

C program to replace last occurrence of a character in a string

Write a C program to replace last occurrence of a character with another in a given string. How to replace last occurrence of a character with another character in a given string using functions in C programming. Logic to replace last occurrence of a character with another in given string.

Example

Input

Input string: Do you love programming.
Input character to replace: .
Input character to replace with: ?

Output

String after replacing last '.' with '?' : Do you love programming?

Read more

C program to trim leading and trailing white spaces from a string

Write a C program to trim both leading and trailing white space characters in a string using loop. How to remove both leading and trailing white space characters in a string using loop in C programming. Logic to delete all leading and trailing white space characters from a given string in C.

Example

Input

Input string: "     Lots of leading and trailing spaces.     "

Output

String after removing leading and trailing white spaces: 
"Lots of leading and trailing spaces."

Read more