{"id":9743,"date":"2022-05-21T08:55:37","date_gmt":"2022-05-21T08:55:37","guid":{"rendered":"http:\/\/fastbitlab.com\/?p=9743"},"modified":"2023-08-03T15:54:30","modified_gmt":"2023-08-03T10:24:30","slug":"microcontroller-embedded-c-programming-introduction-to-functions-in-c","status":"publish","type":"post","link":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\/","title":{"rendered":"Microcontroller Embedded C Programming Lecture 42 | Introduction to functions in &#8216;C&#8217;"},"content":{"rendered":"<div class=\"boldgrid-section\" style=\"background-image: linear-gradient(to left, #eeeeee, #eeeeee);\" data-bg-color-1=\"#EEEEEE\" data-bg-color-2=\"#EEEEEE\" data-bg-direction=\"to left\">\n<div class=\"container\">\n<div class=\"row\" style=\"padding-top: 35px; padding-bottom: 0px; background-image: linear-gradient(to left, #eeeeee, #eeeeee);\" data-bg-color-1=\"#EEEEEE\" data-bg-color-2=\"#EEEEEE\" data-bg-direction=\"to left\">\n<div class=\"col-md-1 col-sm-12 col-xs-12 col-lg-1\">\n<div class=\"boldgrid-shortcode\" data-imhwpb-draggable=\"true\">\n\n<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<div class=\"col-md-10 col-sm-12 col-xs-12 col-lg-10\">\n<h1 class=\"\" style=\"text-align: center; font-size: 38px; border-width: 0px; line-height: 57px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000080;\"><strong>Introduction to functions in &#8216;C&#8217;<\/strong><\/span><\/h1>\n<div class=\"row bg-editor-hr-wrap\" style=\"border-width: 0px; margin-top: -21px;\">\n<div class=\"col-lg-12 col-md-12 col-xs-12 col-sm-12\">\n<div>\n<p>&nbsp;<\/p>\n<div class=\"bg-hr bg-hr-10 color2-color\" style=\"border-style: solid; border-width: 0px 0px 3px;\"><\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p class=\"\" style=\"border-width: 0px; font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">In this article, let&#8217;s learn about Functions in &#8216;C.&#8217; Let&#8217;s learn how to write functions, what a function prototype is, how to call a function, and understand various other things related to functions.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<h2 class=\"\" style=\"border-width: 0px; font-size: 29px; line-height: 39px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #000080;\"><span style=\"font-weight: 400;\">Functions in C<\/span><\/span><\/h2>\n<ul class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">In &#8216;C&#8217;, you write executable statements inside a function.&nbsp;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">In &#8216;C&#8217;, a function is nothing but a collection of statements to perform a specific task.&nbsp;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">Every C program, at least, has one function called &#8220;main.&#8221;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">Using functions bring modularity to your code, easy to debug, modify, and increases the maintainability of the code.&nbsp;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">Using C function also minimizes code size and minimizes code redundancy.&nbsp;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">Functions provide abstraction. For example, printf is a function given by a standard library code. You need not to worry about how it is implemented, and it serves your purpose.&nbsp;<\/span><\/li>\n<\/ul>\n<ul class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">In your program, if you want to perform the same set of tasks again and again, then create a function to do that task and call it every time you need to perform that task.&nbsp;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">This reduces code redundancy and brings more modularity to your program and also decreases the final executable size of your program.<\/span><\/li>\n<\/ul>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 25px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; line-height: 35px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #000080;\"><span style=\"font-weight: 400;\">The general form of a function definition in C<\/span><\/span><\/p>\n<p class=\"\" style=\"padding-left: 40px; border-width: 0px; font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #993300;\"><span style=\"font-weight: 400;\">&nbsp;<\/span><span style=\"font-weight: 400; color: #000000;\">return_data_type <\/span><span style=\"font-weight: 400; color: #ff0000;\">function_name<\/span><span style=\"font-weight: 400; color: #000000;\">(parameter list)<\/span><\/span><\/p>\n<p class=\"\" style=\"padding-left: 80px;\"><span style=\"font-weight: 400; color: #000000;\">{&nbsp;<\/span><\/p>\n<p class=\"\" style=\"padding-left: 80px; border-width: 0px; font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">&nbsp;&nbsp;&nbsp;&nbsp;\/\/ body of the function<\/span><\/p>\n<p class=\"\" style=\"padding-left: 80px;\"><span style=\"font-weight: 400; color: #000000;\">}<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">This is a general form of a function definition in &#8216;C.&#8217; When you write a function, you first have to give a proper name for the function. So, you can follow the same rules that you used to write a variable name.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">And the function always comes with parenthesis. And inside the parenthesis, you have to mention the parameter list. So, these are the input parameters or input arguments to the function. And also, you may mention the return_data_type, which is the data type of the data which the function returns. So, a function may return a value, or it may not return a value.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\"><span style=\"color: #993300;\">return_data_type function_name(parameter list)<\/span> \u2192&nbsp; This is called a function prototype. A function prototype says its return data type, functions name, and its parameter list.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">After that, you have to use the curly brackets, which give the body of the function. And inside the body of the function, you have to write your executable &#8216;C&#8217; statements.&nbsp;<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Let&#8217;s see one example. Create a new project. Let&#8217;s first write the main function.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Main is also a function. Like any other function, which has a function body, return type, the parameter list. But there are two ways you can define the main function in your program according to the standard.&nbsp;<\/span><\/p>\n<figure id=\"attachment_9746\" aria-describedby=\"caption-attachment-9746\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><img fetchpriority=\"high\" decoding=\"async\" class=\"wp-image-9746\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/05\/Figure-1-16-1024x533.png\" alt=\"main function\" width=\"650\" height=\"338\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-1-16-1024x533.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-1-16-300x156.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-1-16-768x399.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-1-16-600x312.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-1-16-1536x799.png 1536w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-1-16-120x62.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-1-16-500x260.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-1-16-200x104.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-1-16-400x208.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-1-16-800x416.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-1-16-1200x624.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-1-16.png 1859w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><figcaption id=\"caption-attachment-9746\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 1. main function<\/span><\/figcaption><\/figure>\n<p data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">You can give the main function definition in two ways.<\/span><\/p>\n<ol class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">\n<li><span style=\"color: #000000;\"><span style=\"color: #000080;\"><b> int main()<\/b><\/span><span style=\"font-weight: 400;\"><span style=\"color: #000080;\"> \u2192<\/span> This is the main function definition with no input arguments. Here we can see that there are no input arguments. When there are no input arguments, you can mention it as void or leave it like this with just a parenthesis.<\/span><\/span><\/li>\n<\/ol>\n<ol class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" start=\"2\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">\n<li><span style=\"color: #000000;\"><span style=\"color: #000080;\"><b>int main(int argc, char* argv[])<\/b><\/span><span style=\"font-weight: 400;\"><span style=\"color: #000080;\"> \u2192<\/span> This is another main function definition with two input arguments. Now, these arguments are also called command-line arguments. We don&#8217;t use this definition of main for embedded systems because, most of the time, there are no command-line arguments in embedded system programming. That&#8217;s why we usually don&#8217;t use this main function definition. So, usually use the first main function.&nbsp;<\/span><\/span><\/li>\n<\/ol>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Let&#8217;s explore some more points about &#8216;main&#8217;.&nbsp;<\/span><\/p>\n<ul class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">\u2018main&#8217; takes only 0 or 2 arguments.&nbsp;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">main() is the special function in C from where execution of a program starts and ends.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">main() function returns the status of a program to the Parent process.<\/span><\/li>\n<\/ul>\n<p class=\"\" style=\"padding-left: 40px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">In this case, the parent process is actually the operating system. Because we are writing application for our windows PC or our machine. So here, there is an operating system, and the operating system launches the application. So, when the application ends, that application returns a code back to the OS and by that OS comes to know whether that process is terminated properly or not.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"padding-left: 40px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">So, the main() function returns the status of the program to the parent process, showing the success or failure of the program. 0 means SUCCESS, and non zero means ERROR.&nbsp;<\/span><\/p>\n<ul class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">main() function suppose to return an <\/span><i><span style=\"font-weight: 400;\">int value<\/span><\/i><span style=\"font-weight: 400;\"> to the calling process as per the standard(C89 and above)<\/span><\/span><\/li>\n<\/ul>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Let&#8217;s write that. When you write the main function, always make sure that the return type is int. This function has to return integer data by using the return statement. So, write return 0. (as shown in below code sippet)<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Now let&#8217;s write a function to add two numbers.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">First, let me give a function name. The function name is <\/span><b>function_add_numbers<\/b><span style=\"font-weight: 400;\">. After that, let&#8217;s give the parenthesis and write the argument list or parameter list. This function takes three input arguments. The arguments are<\/span><b> int a, int b, and int c<\/b><span style=\"font-weight: 400;\">. These are the three input parameters of the function_add_numbers. And let me decide that this function doesn&#8217;t return anything. So, no return value. That&#8217;s why, in that case, you have to mention the keyword <\/span><b>void<\/b><span style=\"font-weight: 400;\"> here. Void is the return type, which means the function doesn&#8217;t return anything.<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">After that, let&#8217;s give the function body. You have to open two curly brackets. So this is called the function definition.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">And after that, inside the function, you have to write the code to add two or three numbers. Let&#8217;s create one more variable <\/span><b>sum<\/b><span style=\"font-weight: 400;\">. Then <\/span><b>sum = a+b+c<\/b><span style=\"font-weight: 400;\">.<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">Remember that the<\/span><b> int sum<\/b><span style=\"font-weight: 400;\"> variable and <\/span><b>int a, int b, int c<\/b><span style=\"font-weight: 400;\"> these variables are the same. All these are local scope variables. So, it is just that these are mentioned to receive the input values for the function. So these are also called formal parameters, or you can call them local scope variables.&nbsp;<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">And after that, let&#8217;s print the sum. <\/span><b>printf(\u201cSum = %d\\n\u201d,sum);<\/b><span style=\"font-weight: 400;\">&nbsp;<\/span><\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"font-size: 12px; box-shadow: #cecece 0px 0px 0px 0px inset;\"><span style=\"color: #993366;\">int<\/span> main()\r\n{\r\n   function_add_numbers(12, 13, 14);\r\n\r\n   function_add_numbers(-20, 20, 14);\r\n\r\n  <span style=\"color: #993366;\"> int<\/span> valueA = 90, valueB = 70;\r\n\r\n   function_add_numbers(valueA , valueB , 90);\r\n\r\n<span style=\"color: #993366;\">return<\/span> 0;\r\n}\r\n\r\n<span style=\"color: #339966;\">\/\/ This is function definition<\/span>\r\n<span style=\"color: #993366;\">void<\/span> function_add_numbers(<strong><span style=\"color: #993366;\">int<\/span><span style=\"color: #ffff00;\"><span style=\"color: #ffffff;\"> a<\/span><span style=\"color: #ffffff;\">,<\/span> <span style=\"color: #993366;\">int<\/span> <span style=\"color: #ffffff;\">b,<\/span> <span style=\"color: #993366;\">int<\/span> <span style=\"color: #ffffff;\">c<\/span><\/span><\/strong>)\r\n{\r\n     <span style=\"color: #993366;\">int<\/span> sum ;\r\n     sum = a+b+c;\r\n   <span style=\"color: #800080;\">  printf<\/span>(\"Sum = %d\\n\", sum);\r\n}<\/pre>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">Now, whenever you want to add three numbers, call the <\/span><b>function_add_numbers<\/b><span style=\"font-weight: 400;\"> function. You can call it from the main or call it from some other function, which means this function is dedicated to adding three numbers.<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Let&#8217;s see how to call this function. I call this function from main. So, I go to the main, write the function name, and give the parenthesis and a semicolon.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"padding-left: 40px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><b>function_add_numbers();<\/b><span style=\"font-weight: 400;\"> This is function calling.<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Here you have to pass the arguments to the function. This function takes three input values of type int. So, you have to do according to that. You have to pass three integer values when you call this function. Let&#8217;s use three integer values like 12, 13, 14. I can call this function one more time to mention -20, +20, 14.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">And after that, you can even pass variables as arguments. Like<\/span><b> int valueA = 90, <\/b><span style=\"font-weight: 400;\">and<\/span><b> valueB<\/b><span style=\"font-weight: 400;\"> = 70. You can even do something like this. So, you can pass valueA, valueB, and third argument you can pass anything you want. I write 90. So, this is also a legal statement. So, it can be a combination of a number and variables.<\/span><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Now let&#8217;s see how it goes. Let&#8217;s compile. It gives various warnings.&nbsp;&nbsp;<\/span><\/p>\n<figure id=\"attachment_9748\" aria-describedby=\"caption-attachment-9748\" style=\"width: 676px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-9748\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/05\/Figure-3-16-1024x564.png\" alt=\"functions in C\" width=\"676\" height=\"373\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-16-1024x564.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-16-300x165.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-16-768x423.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-16-600x330.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-16-1536x846.png 1536w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-16-120x66.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-16-500x275.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-16-200x110.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-16-400x220.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-16-800x440.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-16-1200x661.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-16.png 1789w\" sizes=\"(max-width: 676px) 100vw, 676px\" \/><figcaption id=\"caption-attachment-9748\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 2. Warnings<\/span><\/figcaption><\/figure>\n<p class=\"\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Let&#8217;s try to understand them one by one. The first warning is the implicit declaration of function &#8216;function_add_numbers.&#8217; That means, for the compiler, before calling a function you have to declare that in the same way that you did for variables. So, before using a variable, you have to define a variable, or at least declare a variable that exists somewhere. So, the same rule you have to follow for functions as well. Before using that function, you have to declare to the compiler that it exists somewhere, and we do that by using something called a function declaration, or it is also called function prototyping.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Let&#8217;s explore function prototyping or function declaration in the following article.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-size: 20px; line-height: 25px;\"><span style=\"color: #000080;\"><b>FastBit Embedded Brain Academy Courses<\/b><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-size: 17px;\"><span style=\"color: #000000;\">C<span style=\"font-weight: 400;\">lick here:&nbsp;<\/span><\/span><span style=\"color: #0000ff;\"><a style=\"color: #0000ff; text-decoration: underline;\" href=\"http:\/\/fastbitlab.com\/course1\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">https:\/\/fastbitlab.com\/course1<\/span><\/a><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Introduction to functions in &#8216;C&#8217; &nbsp; &nbsp; In this article, let&#8217;s learn about Functions in &#8216;C.&#8217; Let&#8217;s learn how to write functions, what a function prototype is, how to call a function, and understand various other things related to functions. &nbsp; Functions in C In &#8216;C&#8217;, you write executable statements inside a function.&nbsp; In [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":9746,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"0","ocean_second_sidebar":"0","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"0","ocean_custom_header_template":"0","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"0","ocean_menu_typo_font_family":"0","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"0","ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"off","ocean_gallery_id":[],"footnotes":""},"categories":[8],"tags":[16],"class_list":["post-9743","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-microcontroller-embedded-c-programming","entry","has-media"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Functions in C - Introduction, general form of function definition in C<\/title>\n<meta name=\"description\" content=\"Introduction to functions in C. In &#039;C&#039;, you write executable statements inside a function. A function is nothing but a collection of\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Functions in C - Introduction, general form of function definition in C\" \/>\n<meta property=\"og:description\" content=\"Introduction to functions in C. In &#039;C&#039;, you write executable statements inside a function. A function is nothing but a collection of\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\/\" \/>\n<meta property=\"og:site_name\" content=\"FastBit EBA\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/fastbiteba\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-05-21T08:55:37+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-03T10:24:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-1-16.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1859\" \/>\n\t<meta property=\"og:image:height\" content=\"967\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"FastBitLab\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@fastbiteba\" \/>\n<meta name=\"twitter:site\" content=\"@fastbiteba\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"FastBitLab\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\\\/\"},\"author\":{\"name\":\"FastBitLab\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\"},\"headline\":\"Microcontroller Embedded C Programming Lecture 42 | Introduction to functions in &#8216;C&#8217;\",\"datePublished\":\"2022-05-21T08:55:37+00:00\",\"dateModified\":\"2023-08-03T10:24:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\\\/\"},\"wordCount\":1388,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/Figure-1-16.png\",\"keywords\":[\"Microcontroller Embedded C programming Lectures\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\\\/\",\"name\":\"Functions in C - Introduction, general form of function definition in C\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/Figure-1-16.png\",\"datePublished\":\"2022-05-21T08:55:37+00:00\",\"dateModified\":\"2023-08-03T10:24:30+00:00\",\"description\":\"Introduction to functions in C. In 'C', you write executable statements inside a function. A function is nothing but a collection of\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\\\/#primaryimage\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/Figure-1-16.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/Figure-1-16.png\",\"width\":1859,\"height\":967,\"caption\":\"Figure 1. main function\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Microcontroller Embedded C Programming Lecture 42 | Introduction to functions in &#8216;C&#8217;\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\",\"name\":\"FastBit EBA\",\"description\":\"Your Online Academy of Embedded Systems\",\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\",\"name\":\"FastBit EBA\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/logo-EzNrEnyr.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/logo-EzNrEnyr.png\",\"width\":640,\"height\":640,\"caption\":\"FastBit EBA\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/fastbiteba\\\/\",\"https:\\\/\\\/x.com\\\/fastbiteba\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/fastbit-embedded-brain-academy-b3167b124\\\/\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCa1REBV9hyrzGp2mjJCagBg\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\",\"name\":\"FastBitLab\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"caption\":\"FastBitLab\"},\"description\":\"The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Functions in C - Introduction, general form of function definition in C","description":"Introduction to functions in C. In 'C', you write executable statements inside a function. A function is nothing but a collection of","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\/","og_locale":"en_US","og_type":"article","og_title":"Functions in C - Introduction, general form of function definition in C","og_description":"Introduction to functions in C. In 'C', you write executable statements inside a function. A function is nothing but a collection of","og_url":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\/","og_site_name":"FastBit EBA","article_publisher":"https:\/\/www.facebook.com\/fastbiteba\/","article_published_time":"2022-05-21T08:55:37+00:00","article_modified_time":"2023-08-03T10:24:30+00:00","og_image":[{"width":1859,"height":967,"url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-1-16.png","type":"image\/png"}],"author":"FastBitLab","twitter_card":"summary_large_image","twitter_creator":"@fastbiteba","twitter_site":"@fastbiteba","twitter_misc":{"Written by":"FastBitLab","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\/#article","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\/"},"author":{"name":"FastBitLab","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d"},"headline":"Microcontroller Embedded C Programming Lecture 42 | Introduction to functions in &#8216;C&#8217;","datePublished":"2022-05-21T08:55:37+00:00","dateModified":"2023-08-03T10:24:30+00:00","mainEntityOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\/"},"wordCount":1388,"commentCount":0,"publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-1-16.png","keywords":["Microcontroller Embedded C programming Lectures"],"articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\/","url":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\/","name":"Functions in C - Introduction, general form of function definition in C","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\/#primaryimage"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-1-16.png","datePublished":"2022-05-21T08:55:37+00:00","dateModified":"2023-08-03T10:24:30+00:00","description":"Introduction to functions in C. In 'C', you write executable statements inside a function. A function is nothing but a collection of","breadcrumb":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\/#primaryimage","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-1-16.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-1-16.png","width":1859,"height":967,"caption":"Figure 1. main function"},{"@type":"BreadcrumbList","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-introduction-to-functions-in-c\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fastbitlab.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Microcontroller Embedded C Programming Lecture 42 | Introduction to functions in &#8216;C&#8217;"}]},{"@type":"WebSite","@id":"https:\/\/fastbitlab.com\/blog\/#website","url":"https:\/\/fastbitlab.com\/blog\/","name":"FastBit EBA","description":"Your Online Academy of Embedded Systems","publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fastbitlab.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/fastbitlab.com\/blog\/#organization","name":"FastBit EBA","url":"https:\/\/fastbitlab.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2026\/04\/logo-EzNrEnyr.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2026\/04\/logo-EzNrEnyr.png","width":640,"height":640,"caption":"FastBit EBA"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/fastbiteba\/","https:\/\/x.com\/fastbiteba","https:\/\/www.linkedin.com\/in\/fastbit-embedded-brain-academy-b3167b124\/","https:\/\/www.youtube.com\/channel\/UCa1REBV9hyrzGp2mjJCagBg"]},{"@type":"Person","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d","name":"FastBitLab","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","caption":"FastBitLab"},"description":"The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries."}]}},"_links":{"self":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/9743","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/comments?post=9743"}],"version-history":[{"count":5,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/9743\/revisions"}],"predecessor-version":[{"id":15217,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/9743\/revisions\/15217"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media\/9746"}],"wp:attachment":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media?parent=9743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/categories?post=9743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/tags?post=9743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}