C Programming language

C Standard Library Function

Day 1: Introduction and brief history of C Programming language

Day 1: Advantages and Disadvantages of C, C Keywords, Data type modifiers in C

Day 1: Data types in C Programming language

Day 1: Secondary data types, Primitive and Non-primitive data types

Day 1: C Variables, C Constant, Format Specifiers in C

Day 2: Write first C program

Day 2: Flow of C program with example, main(), printf(), scanf()

Day 2: Operaters in C Programming language, Arithmetic operators

Day 2: Relational operators and Logical Operators in C Programming language

Day 2: Assignment, Increments and Decrement Operators in C Programming language

Day 3: Conditional statement: if else statement in C Programming language

Day 3: Conditional statement: switch statement in C Programming language

Day 3: Jump statements: return statement in C Programming language

Day 3: Jump statements: go to statement in C Programming language

Day 3: Jump statements: break statement in C Programming language

Day 3: Jump statements: continue statement in C Programming language

Day 4: Loops OR Iteration statement in C Programming language: for Loop

Day 4: Loops OR Iteration statement in C Programming language: while Loop

Day 4: Loops OR Iteration statement in C Programming language: do while Loop

Day 5: Array in C Programming language

Day 5: Access elements of Array in C Programming language

Day 5: One dimensional Array representation in memory using C Programming language

Day 5: Two dimensional Array representation in memory using C Programming language

Day 5: Multidimensional Array in C Programming language

Day 6: Function in C Programming language

Day 6: Definition, Declaration and Calling a Function in C Programming language

Day 6: Passing array to a function in C Programming language

Day 6: Calling Function in C Programming language : Call by value

Day 6: Calling Function in C Programming language : Call by reference

Day 6: Recursive Function in C Programming language

Day 6: Adding function to the library in C Programming language

Day 7: Pointer in C Programming language, How to use Pointer, Pointer declaration

Day 7: NULL Pointers in C Programming language

Day 7: Array of Pointers in C Programming language

Day 7: Pointer arithmetic in C Programming language

Day 7: Pointer to Pointer in C Programming language

Day 7: Pointer to Function in C Programming language: Passing pointers to functions

Day 7: Pointer to Function in C Programming language: Return pointer from functions

Day 8: Strings in C Programming language, Declaring String in C Programming language

Day 8: String functions in C Programming language

Introduction of Structure

Accessing the members of Structure

Structure With typedef Keyword and Use of sizeof function

Example of Structure

Dynamic memory allocation in C: Introduction

adplus-dvertising
Day 6 Calling Function in C Programming language : Call by value
Previous Home Next

If a function is to use arguments, it must declare variables that accept the values of the arguments. While calling a function, there are two ways that arguments can be passed to a function:

  • Call by value
  • Call by reference

# Call by value

Whenever we called a function and passed something to it we have always passed the 'Values' of variables to the called function. Such function is called Call By Value.

Defining a Function: Consider the fuction factorial()

/* Factorial of a number */
int factorial(int x)
{
	int f=1,i; /* local variable declaration */
	for(i=x; i>=1; i--)
	f=f*i;
	return(f);
}

Now, let us call the function factorial() by passing actual values as in the following example:

#include <stdio.h>
#include <conio.h>

/* function declaration */
int factorial (int);
void main
{
	int a, fact; /* local variable declaration */
	clrscr();
	printf("\n Enter any number");
	scanf ("%d",&a);/* calling a function of factorial of a number */
	fact=fatorial(a); /* local variable declaration */
	printf("factorial value=%d",fact);
}

/* Factorial of a number */
int factorial(int x)
{
	int f=1,i; /* local variable declaration */
	for(i=x; i>=1; i--)
	f=f*i;
	return(f);
}

Output : Enter any number: 5
factorial value=120

Previous Home Next