Using two user-defined functions together in C with example.

Photo by Sigmund on Unsplash

Using two user-defined functions together in C with example.

So here we are now we gonna use two different user-defined functions to make a program. I won't go into the basics of c. This reading is for people who are already familiar with c. So let's say we gonna write two functions one is for calculating the cube of a number and the other is for square.

#include <stdio.h>



int cube(int n);
int square(int m);
int main ()
{
    int a, b, c, s;
    printf("enter a and b : ");
    scanf("%d%d",&a,&b);

    c = cube (a);
      s = square (b);

    printf("The cube is %d\nThe square is %d",c,s);

    return(0);

}

int cube(int n)
{
    int c;
    c = n * n * n;


    return (c);
}
int square(int m)
{
    int s;
    s = m * m;


    return (s);
}

output :

enter a and b : 4
4
The cube is 64
The square is 16

"With practice and consistency, you can do wonders."