Write a C program to create and include your custom header file. How to create and include your own header file in C programming. C program to include another C program and custom header files.
Function
How to pass function pointer as parameter in C?
Write a C program to pass function pointer as parameter to another function. How to pass functions as parameter to another function in C programming.
How to return multiple value from function in C programming?
Write a C program to return multiple value from function. How to return more than one value from function in C programming? Different ways to return multiple value from function in C programming.
C program to multiply two matrix using pointers
Write a C program to multiply two matrix using pointers. How to input and multiply two matrix using pointer in C programming. Logic to multiply two matrix using pointer in C.
Example
Input
Input elements of matrix1: 10 20 30 40 50 60 70 80 90 Input elements of matrix2: 1 2 3 4 5 6 7 8 9
Output
Product of matrices is : 300 360 420 660 810 960 1020 1260 1500
How to access two dimensional array using pointers in C programming?
How to access two dimensional array using pointers in C programming? Write a C program to input and print elements of a two dimensional array using pointers and functions.
Example
Input
Input elements in 3x3 matrix: 1 2 3 4 5 6 7 8 9
Output
Elements of 3x3 matrix: 1 2 3 4 5 6 7 8 9
How to pass and return array from function in C?
Functions makes our program modular and maintainable. Big applications can have hundreds of functions.
Array is a data structure to store homogeneous collection of data. Arrays are equally important as functions. In programming we often use arrays and functions together.
Here in this post I will explain how to pass and return array from function in C programming.
C program to sort an array using pointers
Write a C program to input elements in an array and sort array using pointers. How to sort an array in ascending or descending order using function pointers in C programming. Logic to sort an array using pointers in program.
Example
Input
Input array elements: 10 -1 0 4 2 100 15 20 24 -5
Output
Array in ascending order: -5, -1, 0, 2, 4, 10, 15, 20, 24, 100, Array in descending order: 100, 24, 20, 15, 10, 4, 2, 0, -1, -5,
C program to search element in array using pointers
Write a C program to input elements in array and search an element in array using pointers. How to search an element in array using pointers in C programming. Logic to search an element in array using pointers in C program.
Example
Input
Input array elements: 10 20 30 40 50 60 70 80 90 100 Input element to search: 25
Output
25 does not exists in array.
Variable length arguments (var-args) in C
Quick links
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?