List of practical programmes in C Language for M. Tech / M.C.A., / B.E./ B.Tech./ Computer Science / B.Sc. / BCA PRACTICAL PROGRAMMING & PROBLEM SOLVING THROUGH C - I / II
#include "stdio.h"
void swap_function(int *, int *); //function declaration
int main()
{
// varibale declaration
int first_no, second_no;
// taking two input from user
printf("Enter the value of first number :");
scanf("%d", &first_no);
printf("Enter the value of second number :");
scanf("%d", &second_no);
// printing the value of first_no, second_no in main() function, before swap_function call
printf("Before calling swap_function (),the values in main () function first_no = %d, second_no = %d\n\n",first_no,second_no);
// swap_function call
swap_function(&first_no,&second_no);
//printing the value of first_no, second_no in main() function, after swap_function call
printf("After calling swap_function (), the values in main () function first_no = %d, second_no = %d\n\n",first_no,second_no);
return 0;
}
// function definition
void swap_function (int *first, int *second)
{
int temp_var;
temp_var = *first;
*first=*second;
*second=temp_var;
printf("After swapping values in swap_function() first = %d, second = %d\n",*first,*second);
}