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.
Programming
Function arguments in C – Call by value and Call by reference
Quick links
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.
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.
Infinite loops in C – Use and Debugging
Infinite loop is a looping construct that iterates forever. In programming life either intentionally or unintentionally, you come across an infinite loop. Generally a program in an infinite loop either produces continuous output or does nothing. Infinite loops are also known as indefinite or endless loop.
As a novice programmer, you must know how to debug an infinite loop. As an intermediate programmer you must know how and when to use infinite loop. Let us first learn when to use infinite loop and how to define.
goto statement in C
goto
is a jump statement used to transfer program control unconditionally from one part of a function to another. I have used the word unconditionally because there is no restriction on control transfer. You can transfer program control from one position to any position within a function. Many programmers uses goto
to gain full control on their program.
continue statement in C
In the series of learning C programming, we learned to repeat a set of statements and terminate a repetitive statement using break
. Here in this post, I will explain another program flow control statement i.e. continue
.
break statement in C
Until now, we have learned to execute statements based on conditions using if…else statement. We also learned to execute repetitive statements using for loop, while loop and do…while loop.
In this post I will explain the use and importance of break
statement in program flow control.
Nested loops in C programming
In the series of learning flow control statements we learned to iterate set of statements using loop. Here in this post we learn to write one loop inside other.
Do…while loop in C programming
C programming supports three types of looping statements for loop, while loop and do...while
loop. Among three do...while
loop is most distinct loop compared to others.
do...while
is an exit controlled looping statement. We use do...while
loop when there is a need to check condition after execution of loop body. do...while
loop in any case executes minimum once.
While loop in C programming
Quick links
In previous post, we began our discussion on looping statements and learned for loop. In this post we will continue our discussion on while
loop.