
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
What is call by value in C language?
Pass by value or call by value are sent as arguments.
Algorithm
Refer to the algorithm for the call by value.
Step 1: Enter any 2 numbers at runtime Step 2: Read those two numbers from console Step 3: Call the function swap with arguments is a call by value Step 4: Go to called function swap(int a,int b) Step 5: Print the numbers after swap
Example
Following is the C program for the call by value −
#include<stdio.h> void main(){ void swap(int,int); int a,b; clrscr(); printf("enter 2 numbers"); scanf("%d%d",&a,&b); printf("Before swapping a=%d b=%d",a,b); swap(a,b); printf("after swapping a=%d, b=%d",a,b); getch(); } void swap(int a,int b){ int t; t=a; a=b; b=t; }
Output
When the above program is executed, it produces the following result −
enter 2 numbers 10 20 Before swapping a=10 b=20 After swapping a=10 b=20
- Related Articles
- What is call by reference in C language?
- What is pass by value in C language?
- Call by value and Call by reference in Java
- Difference between Call by Value and Call by Reference
- What is pass by reference in C language?
- Is JavaScript a pass-by-reference or pass-by-value language?
- What is malloc in C language?
- What is Calloc in C language?
- What is Realloc in C language?
- What do you mean by buffer in C language?
- Java Program to Demonstrate the Call By Value
- What is a recursive method call in C#?
- What is C++ programming language?
- What is strncpy() Function in C language?
- What is strrev() Function in C language?

Advertisements