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.