Q:
Write a C Program to return more than one value from a function
belongs to collection: C Pointer Solved Programs – C Programming
C Pointer Solved Programs – C Programming
- C Program to Access elements of an array using pointer
- Write a C Program to Swap Two Numbers Using Call by Reference
- C Program to Find Largest Number Using Dynamic Memory Allocation
- Write a C Program to Sort Infinite Numbers in Ascending Order
- Write a C program to Swap two numbers using pointers
- Write a C Program to Reverse each word in string using pointers
- Write a C Program to reverse string using pointers and function
- Write a C Program to find largest number using pointers
- Write a C Program to find sum and average of n numbers using pointers
- C Program to Sort n numbers in ascending order using pointers
- C Program to check string is palindrome or not using pointers
- Write a C Program to Get Address of array using Pointers
- C program to count number of vowels and consonants in a string using pointer
- Write a C program for Student details using pointer and structure
- Write a C program to Print string using pointers
- Write a C program to print size of different data types using pointers
- C program to perform double pointer or Pointer to Pointer
- Write a C program to perform Array of pointers
- Write a C Program to implement Stack Operations Using Pointer
- Write a C Program to Find Length of String using Pointers
- Write a C Program to Reverse array using Pointers
- Write a C Program to display array with addresses using pointers
- Write a C Program for Addition of Two Numbers Using Pointers
- Write a C Program to dereference pointer variables
- Write a C Program to show an example of pointer to pointer
- C Program to print value and address of elements of an array using pointer
- Write a C Program to perform Call By Value and Call By Reference methods
- Write a C Program to return more than one value from a function
- Write a C Program for dynamic memory allocation using malloc( )
- Write a C Program to understand the use of realloc() function
- Write a C Program to understand pointers to structures
- Write a C Program to understand how pointer to structure variable is sent to function
- Write a C Program to understand how pointer to structure returned from function
Call by Reference
If data is passed by reference, a pointer to the data is copied instead of the actual variable as is done in a call by value. Because a pointer is copied, if the value at that pointers address is changed in the function, the value is also changed in main().
In call by reference, original value is modified because we pass reference (address).
Here, address of the value is passed in the function, so actual and formal arguments shares the same address space.
Hence, value changed inside the function, is reflected inside as well as outside the function.
In this program, we pass the variables or arguments to the function and uses pointer to calculate Sum, Difference and Multiplication of variables and return multiple values after function call.
Below is the source code for C Program to return more than one value from a function using Call By Reference which is successfully compiled and run on Windows System to produce desired output as shown below :
SOURCE CODE : :
OUTPUT : :
need an explanation for this answer? contact us directly to get an explanation for this answer