
- 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
Explain the pointers for inter-function communication in C language.
We know that functions can be called by value and called by reference.
- If the actual parameter should not change in called function, pass the parameter-by value.
- If the value of actual parameter should get changed in called function, then use pass-by reference.
- If the function has to return more than one value, return these values indirectly by using call-by-reference.
Example
Following is the C program for the demonstration of returning the multiple values −
#include<stdio.h> void main() { void areaperi(int,int*,int*); int r; float a,p; printf("enter radius of circle:
"); scanf("%d",&r); areaperi(r,&a,&p); printf("area=%f
",a); printf("perimeter=%f",p); } void areaperi(int x,int *p,int *q) { *p=3.14*x*x; *q=2 * 3.14*x; }
Output
When the above program is executed, it produces the following output −
Enter radius of circle: 5 Area=78.50000 Perimeter=31.40000
Note
- Pointers have a type associated with them. They are not just pointer types, but rather are the pointer to a specific type.
- The size of all pointers is same, which is equal to size on int.
- Every pointer holds the address of one memory location in computer, but the size of a variable that the pointer refers can be different.
- Related Articles
- Explain the concept of pointers in C language
- Explain the pointers to unions in C language
- Explain array of pointers in C programming language
- Explain Arithmetic operations using pointers in C language?
- Explain Near Far Huge pointers in C language
- Explain the concepts of Pointers and arrays in C language
- Explain pointers and one-dimensional array in C language
- Explain pointers and two-dimensional array in C language
- Inter thread communication in Java
- What is Inter process communication?
- Explain Squeeze Function C language
- What is inter process communication (IPC)?
- Explain recursive function in C language with program
- Demonstrate the concept of pointers using C language
- What are pointers to structures in C language?

Advertisements