C Program For Call by Reference

Get Certified in C Programming and Take Your Skills to the Next Level

Program 1

#include<stdio.h>
#include<conio.h>
# include "E:\C-Data-New\includes\dataflair.h"
void display(int *);
void swap(int * ,int *);
void main()
{
      int a,b;
      printf("Enter two number");
      scanf("%d%d",&a,&b);
      printf("\n Before swaping %d %d",a,b);
      swap(&a,&b);
      printf("\n After swaping %d %d",a,b);
      swap(&a,&b);
}
void swap(int *p,int *r)
{
      int c;
      c=*p;
      *p=*r;
      *r=c;
}

Program 2

int addition(int a,int b)
{
    int c;
    c=a+b;
    return c;
}
int reverse(int n)
{
    int r,s=0;
    while(n!=0)
    {
        r=n%10;
        s=s*10+r;
        n=n/10;
    }
    return s;
}
int maxvalue(int a,int b)
{
    if(a>b)
      return 1;
      else
      return 0;
}
int factorial(int n)
{
    int f=1;
    while(n!=0)
    {
        f=f*n;
        n--;
    }
    return f;
}
void display(int *a)   
{
         *a=*a+10;
}
// void swap(int *p,int *r)
// {
//       int c;
//       c=*p;
//       *p=*r;
//       *r=c;
// }

 

Did we exceed your expectations?
If Yes, share your valuable feedback on Google

courses

TechVidvan Team

TechVidvan Team provides high-quality content & courses on AI, ML, Data Science, Data Engineering, Data Analytics, programming, Python, DSA, Android, Flutter, full stack web dev, MERN, and many latest technology.

Leave a Reply

Your email address will not be published. Required fields are marked *