C Program for Call by Value and Return by Value

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

Program 1

// Program for call by value and return by value
#include<stdio.h>
#include<conio.h>
int factorial(int);
int reverse(int);
float area(float r);
void main()
{
    float A;
    A=area(12.33);
    printf("Area is %f",A);
    // int x,y;
    // printf("Enter a number");
    // scanf("%d",&x);

    // y=reverse(x);
    // printf("\nReverse is %d",y);
    // if(x==y)
    // printf("\nNo is Palindrom...");
    // else
    // printf("\nNo is not Palindrom...");
    // y=factorial(x);
    // printf("Factorial is %d",y);
}

// Developer Task
int factorial(int n)
{
    int f=1;
    while(n!=0)
    {
        f=f*n;
        n--;
    }
    return(f);
}
int reverse(int n)
{
      int r,s=0;
      while(n!=0)
      {
        r=n%10;
        s=s*10+r;
        n=n/10;
      }
      return(s);
}
float area(float r)
{
    float A;
    A=3.14*r*r;
    return(A);
}

 

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 *