Lesson 19 of 23

Call by Reference: Swap

9 min 35 XP

Variable का address भेजें तो function उस variable को ही बदल सकता है। scanf(&x) ठीक ऐसे ही काम करता है, और इसी तरह कोई function एक से ज़्यादा values लौटाता है।

Example: edit me and press Run

Output Loading C (first time takes a few seconds)
Press Run to see the result here.

Function को array भेजने पर उसके पहले तत्व का address जाता है, इसलिए function में किए बदलाव main में भी दिखते हैं।

Challenge

+35 XP

void divide(int a, int b, int *q, int *r) लिखें जो भागफल q में और शेषफल r में रखे। main() में a और b पढ़ें और print करें: Input: 17 5 Output: Quotient 3, Remainder 2

Output Loading C (first time takes a few seconds)
Press Run to see the result here.