Home » Find Square of a Number Using more than One Functions

Find Square of a Number Using more than One Functions

Learn about Find Square of a Number Using more than One Functions in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

Contents

Find Square of a Number Using more than One Functions

Source code:

#include<stdio.h>

int getNumber();
int square(int n);
void display(int n, int sqr);

int main()
{
   int num = getNumber();
   int result = square(num);
   display(num, result);
   return 0;
}

int getNumber()
{
   int n;
   printf("Enter an Integer number: ");
   scanf("%d",&n);
   return n;
}

// function for finding square value
int square(int n)
{
   return n*n;
}

// function for printing result
void display(int n, int sqr)
{
   printf("Square of %d = %d\n", n, sqr);
}

Output:

Enter an Integer number: 5
Square of 5 = 25

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
Find Minimum & Maximum in Three Numbers by Function
Find the Absolute Value of a Number by Defining a User-defined Function