What is pointer? Give its benefits. Write a program to do swapping of two elements using function with two pointers as arguments. : GTU Nov-Dec 2010

#include<stdio.h>
#include<conio.h>

void SwappingOfNumbers(int *,int *);
main()
{
    int no1,no2;
    clrscr();
    no1 = 10;
    no2 = 20;
    printf("Current value of no1 and no2 is : %d and %d ",no1,no2);
    swapNumbers(&no1,&no2);
    printf("\n\nAfter swapping value of no1 and no2 is : %d and %d ",no1,no2);
    getch();
}
void SwappingOfNumbers(int *no1,int *no2)
{
    int temp;
    temp = *no1;
    *no1 = *no2;
    *no2 = temp;
}

Post a Comment

0 Comments