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

भागाकार q मध्ये आणि बाकी r मध्ये ठेवणारे void divide(int a, int b, int *q, int *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.