• Skip to primary navigation
  • Skip to content

W.W.

The Spirit To Achieve The Best

Main navigation

  • Home.
  • All Contents.
  • Blog.
  • About.
  • Contact.
You are here: Home / World Of Programming / Simple Example OF Subroutines In C Programming

Simple Example OF Subroutines In C Programming

kaleidoscope + subroutines In C Programming

CODE:

//include the required libraries here
void main()
{
int input01, input02, result;

//give some inputs, but you can make it this C program interactive
input01 = 25;
input02 = 10;

result = multiply(input01,input02);    //subroutine call

printf(“Multiplication of %d and %d is %d”,input01,input02,result);
}

/* subroutine definition block */
int multiply(int x, int y)
{
return x*y;
}

OUTPUT:

Multiplication of 25 and 10 is 250

When execution starts and encounters the statement ‘result = multiply(input01,input02);‘, execution goes to the function or subroutine call. We can visualise it as follows:

VISUALISATION:

int multiply(25, 10)
{
return 25*10;   //computes and returns 250
}

Therefore, multiply() returns its result which is stored into the variable ‘result‘. After the value is returned, execution goes back to main and proceeds to the next statement.

Other Simple C Programming Tutorials:
=> Random Numbers in C programming
=> It’s Too Easy To Make This Simple, But Worse, Logical Error In Programming
=> Format Specifiers Used In C Programming
=> A simple Interactive C Program Using Scanf Function

Reader Interactions

Leave a Reply Cancel reply

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

© 2006-2017 · WAKISH WONDERZ - THE SPIRIT TO ACHIEVE THE BEST ·

  • Writing Tips by Wakish
  • Disclaimer
  • Archives
  • Advertise