eHow launches Android app: Get the best of eHow on the go.
Summary: In order to use functions in C, include the standard input/output library in a small program. Find out how to run a program and include functions with help from a software developer in this free video on computer functions.
Dave Andrews is a software developer with a business and Web site selling programs and other computer services in Franklin, Tenn. Having worked in the IT industry for more than 8...read more
"Hi. My name's Dave Andrews. Today I'm going to show you how to use functions in C. Let's go to our computer. And I have a small program already written. I'm going to look at it here. Now in this program, as you can see, the very first thing I do is include the standard input output library. And the reason I do that is so I can have my print F function to display information on the screen. Now this is my little function I've created. It's basically called the my function. It returns an integer and I can tell that because I have the word int before the name of the function. Basically it goes the return type, which is an integer and then the name of the function which is my function and opening parenthesis and then the parameters that go to that function. And a closing parenthesis. Now in this case there's only one parameter to this function and that's another integer that I'm going to call a int A. Now I could have a thousand parameters here of all different types, but this function only takes one, int A. And what this function does is it's going to return A plus one. Now it's going to add one to A and then it uses the return key word to return the result and of the type that was specified here. So if I pass int five, I'll get five plus one passed as return result for my function. Now down here in my main function, I'm calling a print F and then I have a percent D to display a decimal item and then slash R to create a new line. And then I call my function by basically typing the name of the function, my function and opening parenthesis and the value I would like to pass in. Which I'm passing five, close parenthesis. Now before I run this program, I have to make one change. I'm only doing a slash R here, which is a carriage return, but that won't give me a new line. So I'm going to replace that R with a slash N to get a new line. Let's save our program here and compile it. Using a GCC, I'm going to run the results. As you can see, I passed in five and the result that I got from my function was six. It's that easy to use functions in C. My name's Dave Andrews and I've just told you how to use functions in C."
eHow Article: How to Use Functions In C