C Examples

WAP in C Which shows sending & receiving values between functions!

The Program in C Which shows sending & receiving values between functions is given below:

#include <stdio.h>

// Function to receive a value
void receiveValue(int* value) {
    printf("Enter a value: ");
    scanf("%d", value);
}

// Function to send a value
void sendValue(int* value) {
    printf("Sent value: %d\n", *value);
}

int main() {
    int x;

    // Receive a value from the user
    receiveValue(&x);

    // Send the value of x to the sendValue function
    sendValue(&x);

    return 0;
}

Output:

Sent value: 5
Received value: 5

Pro-Tips💡

In this program, there are two functions sendValue() and receiveValue() .

The main() function declares an integer variable x . Then it calls the receiveValue() function and passes the address of x to it.

The receiveValue() function receives the address and prompts the user to enter a value and scans the value and assigns it to the x.

After that, the main() function calls the sendValue() function and passes the address of x to it. The sendValue() function receives the address and dereferences it and prints it.

This program demonstrates how to send and receive values between functions using pointers and function calls with address arguments.

Learn C-Sharp ↗

C-sharp covers every topic to learn about C-Sharp thoroughly.

Learn C Programming ↗

C-Programming covers every topic to learn about C-Sharp thoroughly.

Learn C++ Programming↗

C++ covers every topic to learn about C-Sharp thoroughly.

Codeauri is Code Learning Hub and Community for every Coder to learn Coding by navigating Structurally from Basic Programming to Front-End Development, Back-End Development to Database, and many more.

Related Posts

C# Program to Find Sum of Rows & Columns of a Matrix

The Program in C# Program to Find Sum of Rows & Columns of a Matrix is given below: Output: Hello Codeauri Family,enter the number of rows and columns…

C# Program to Calculate Determinant of Given Matrix

The Program in C# Program to Calculate Determinant of Given Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns of the matrix…

C# Program to Find Sum of right Diagonals of a Matrix

The Program in C# Program to Find Sum of right Diagonals of a Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns…

C# Program to Find Transpose of Given Matrix

The Program in C# Program to Find Transpose of Given Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns in the matrix:22Enter…

C# Program for Multiplication of two square Matrices

The Program in C# Program for Multiplication of two square Matrices is given below: Output: Hello Codeauri Family, enter the number of rows/columns in the matrices:2Enter the elements…

C# Program to Delete Element at Desired position From Array

The Program in C# Program to Delete Element at Desired position From Array is given below: Output: Hello Codeauri Family, enter the number of elements in the array:4Enter…

Leave a Reply

Your email address will not be published. Required fields are marked *

Your Journey into Code Begins Now: Discover the Wonders of Basic Programming

X