Tuesday, February 26, 2019

Demonistration of function using Call By Reference

Function : A function is a group of statements that together perform a task.A function declaration tells the compiler about a function's name, return type, and parameters. A function definition provides the actual body of the function.

File Name : callbyreference.c
//program to swap two numbers using functions - callbyreference

#include<stdio.h>
 void main()
{
  int a=10,b=50;
  void swap(int *,int *);
  clrscr();
  printf("Before Swapping: %d %d\n",a,b);
  swap(&a,&b);
  printf("After Swapping: %d %d\n",a,b);
}
void swap(int *a,int *b)
{
  int t;
  t=*a;
  *a=*b;
  *b=t;
}

Output :
Before Swapping: 10 50
After Swapping: 50 10

No comments:

Post a Comment

Hadoop Commands

HADOOP COMMANDS OS : Ubuntu Environment Author : Bottu Gurunadha Rao Created: 31-Jan-2022 Updated: 31-Jan-2022 Release  : 1.0.1 Purpose: To ...

Search This Blog