Tag Archives: Programming

Multi-dimensional array in C – Declare, initialize and access

Multi-dimensional array is an array of array or more precisely collection of array. Unlike one-dimensional array, multi-dimensional array stores collection of array.

Let us revise the concept of dimension.

  • One-dimensional array : Collection of data/values.
  • Two-dimensional array : Collection of one-dimensional array.
  • Three-dimensional array : Collection of two-dimensional array.
  • N-dimensional array : Collection of N-1 dimensional array.

Continue reading Multi-dimensional array in C – Declare, initialize and access

Arrays in C – Declare, initialize and access

Array is a data structure that hold finite sequential collection of homogeneous data.

To make it simple let's break the words.

  • Array is a collection - Array is a container that can hold a collection of data.
  • Array is finite - The collection of data in array is always finite, which is determined prior to its use.
  • Array is sequential - Array stores collection of data sequentially in memory.
  • Array contains homogeneous data - The collection of data in array must share a same data type.

Continue reading Arrays in C – Declare, initialize and access

Local variables in C

Local variables are variables declared within a function or more specifically say within a block.

Block is a sequence of statements grouped together inside a pair of curly braces { and }. Since the first day of programming, you have been using blocks. For example - if...else block, loop block, function block etc.

Continue reading Local variables in C

Variable length arguments (var-args) in C

In the journey of learning C functions, we learned many concepts related to functions. We learned to define our own function, passing arguments to a function, returning value from a function, recursive function etc. In this chapter, I will talk something interesting about passing variable length arguments to a function.

Have you ever wondered how functions like printf() and scanf() works? As they readily accept any number of arguments passed. You can say -

printf("Learning at Codeforwin");                // Single argument
printf("Codeforwin was founded in %d", 2015);    // Two arguments
printf("Today is %d-%d-%d", 19, 9, 2017);        // Four arguments

In real you can pass n number of arguments to printf(), but how it works?

Continue reading Variable length arguments (var-args) in C

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.

Continue reading Recursion in C programming