Posts

Showing posts with the label Pointers in C

C Program to Swap Values of Two Variables Using Function (Call by Reference) फंक्शन (कॉल बाय रिफरेन्स) का उपयोग करके दो वेरिएबल की वैल्कयू स्वैप करने का C प्रोग्राम

In C language, we can swap the values of two variables using pointers. The addresses of the actual arguments are passed to the function, allowing the function to modify the original variables. C भाषा में Pointers का उपयोग करके दो variables की values को swap किया जा सकता है। इसमें actual arguments के addresses function को पास किए जाते हैं, जिससे function original variables की values को बदल सकता है। C Program #include <stdio.h> void swap(int *x, int *y); int main(void) { int a, b; printf("Enter two integer numbers:\n"); scanf("%d %d", &a, &b); printf("Before swapping: A = %d and B = %d\n", a, b); swap(&a, &b); printf("After swapping: A = %d and B = %d\n", a, b); return 0; } void swap(int *x, int *y) { int z; z = *x; *x = *y; *y = z; } Output Enter two integer numbers: 10 20 Before swapping: A = 10 and B = 20 After swapping: A = 20 and B = 10 Explanation (व्याख्या) Two integer numbers...