Lesson 19 of 23

Call by Reference: Swap

9 min 35 XP

Variable-এর address পাঠালে function সেই variable-টিই বদলাতে পারে। scanf(&x) ঠিক এভাবেই কাজ করে, আর এভাবেই একটি function একাধিক value ফেরত দেয়।

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.