Tutorial 4_Q2

Swap two values stored in two different variables.

               #include <stdio.h>

              int main ()

             {

                       int x,y=10,z=20;

                        printf("value of x before swap : %d\n",y);

                        printf("value of z before swap : %d\n",z);

                        x=y;

                        y=z;

                        z=x;

                        printf("value of y after swap : %d\n",y);

                        printf("value of z after swap : %d\n",z);

                        return 0;

               }

0 comments:

Post a Comment