How to swap two numbers by using function

How to swap two numbers by using function 

int main (void)
{
int a = 10;
int b = 20;

printf("current value of a: %d\n", a);
printf("current value of b: %d\n" b);
//call function func1 to swap the values
Func1(&a,&b);
return 0;
}

voud func1(int *a, int *b)
{
int temp;
temp = *a;
*a = *b;
*b = temp;
printf("value of a: %d\n", *a);
printf("value of b: %d", *b);

}

Pointer is essential in C programming. Take note I used pointer to swap the values in function func1.

Image result for swap two no by using function

1 comment:

  1. Toning your body for summer is necessary for the good beach days, but what about staying fit for the entire year? What if you get one shop stop that offers you sports training, aerobic classes as well as la fitness signature club

    ReplyDelete