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.