{"id":10272,"date":"2022-07-09T06:28:58","date_gmt":"2022-07-09T06:28:58","guid":{"rendered":"http:\/\/fastbitlab.com\/?p=10272"},"modified":"2023-08-26T14:36:59","modified_gmt":"2023-08-26T09:06:59","slug":"microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation","status":"publish","type":"post","link":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation\/","title":{"rendered":"Microcontroller Embedded C Programming Lecture 66| Scanf exercise implementation"},"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: 30px; border-width: 0px; line-height: 50px;\"><span style=\"color: #000080;\"><strong>Scanf exercise implementation<\/strong><\/span><\/h1>\n<div class=\"row bg-editor-hr-wrap\" style=\"border-width: 0px; margin-top: -25px;\">\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 do a scanf exercise. The exercise is, Write a program which takes 3 numbers from the user. And the program should compute the average of those numbers, and the result must be printed.&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;\">Now let&#8217;s create a new project. Here we are creating a project for our PC, not for the embedded board. So, select the C\/C++ project.<\/span><\/p>\n<figure id=\"attachment_10275\" aria-describedby=\"caption-attachment-10275\" style=\"width: 703px\" class=\"wp-caption aligncenter\"><img fetchpriority=\"high\" decoding=\"async\" class=\"wp-image-10275 \" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/07\/Figure-1-11-1024x470.png\" alt=\"Figure 1. Creating a new project\" width=\"703\" height=\"323\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-1-11-1024x470.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-1-11-300x138.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-1-11-768x353.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-1-11-600x275.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-1-11-1536x705.png 1536w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-1-11-120x55.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-1-11-500x230.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-1-11-200x92.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-1-11-400x184.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-1-11-800x367.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-1-11-1200x551.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-1-11.png 1915w\" sizes=\"(max-width: 703px) 100vw, 703px\" \/><figcaption id=\"caption-attachment-10275\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 1. Creating a new project<\/span><\/figcaption><\/figure>\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\u2019s give the name Average.<\/span><\/p>\n<figure id=\"attachment_10276\" aria-describedby=\"caption-attachment-10276\" style=\"width: 703px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-10276 \" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/07\/Figure-2-10-1024x681.png\" alt=\"Figure 2. C Project\" width=\"703\" height=\"468\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-2-10-1024x681.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-2-10-300x199.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-2-10-768x511.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-2-10-600x399.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-2-10-120x80.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-2-10-500x332.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-2-10-200x133.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-2-10-400x266.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-2-10-800x532.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-2-10-1200x798.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-2-10.png 1343w\" sizes=\"(max-width: 703px) 100vw, 703px\" \/><figcaption id=\"caption-attachment-10276\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 2. C Project<\/span><\/figcaption><\/figure>\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;\"><span style=\"color: #000000;\">Then, let\u2019s create a new source file. Right-click on Project, select New, and select Source File.<\/span> <\/span><\/p>\n<figure id=\"attachment_10277\" aria-describedby=\"caption-attachment-10277\" style=\"width: 710px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-10277 \" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/07\/Figure-3-7-1024x724.png\" alt=\"Figure 3. Creating a Source file \" width=\"710\" height=\"502\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-3-7-1024x724.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-3-7-300x212.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-3-7-768x543.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-3-7-600x424.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-3-7-120x85.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-3-7-500x353.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-3-7-200x141.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-3-7-400x283.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-3-7-800x565.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-3-7-1200x848.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-3-7.png 1445w\" sizes=\"(max-width: 710px) 100vw, 710px\" \/><figcaption id=\"caption-attachment-10277\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 3. Creating a Source file<\/span><\/figcaption><\/figure>\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;\">&nbsp;<span style=\"color: #000000;\">Let me name it main.c.<\/span><\/span><\/p>\n<figure id=\"attachment_10278\" aria-describedby=\"caption-attachment-10278\" style=\"width: 704px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10278 \" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/07\/Figure-4-7.png\" alt=\"Figure 4.Source File \" width=\"704\" height=\"476\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-4-7.png 979w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-4-7-300x203.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-4-7-768x519.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-4-7-600x405.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-4-7-120x81.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-4-7-500x338.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-4-7-200x135.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-4-7-400x270.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-4-7-800x540.png 800w\" sizes=\"(max-width: 704px) 100vw, 704px\" \/><figcaption id=\"caption-attachment-10278\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 4.Source File<\/span><\/figcaption><\/figure>\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;\">First, let&#8217;s create a variable. Let&#8217;s create 3 variables. <\/span><b>float number1, number2, number3<\/b><span style=\"font-weight: 400;\">; Users may enter a real number, which is also possible. So, let&#8217;s take a float here.&nbsp; And now, let me also create another variable. <\/span><b>float average<\/b><span style=\"font-weight: 400;\">; To store the average value.<\/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;\">After that, now let&#8217;s first ask the user to enter the first number. <\/span><b>Printf(&#8220;Enter the first number:&#8221;);<\/b><span style=\"font-weight: 400;\">&nbsp; Let me not give \\n here. So, let a user enter after this colon. I would give this message &#8220;Enter the first number&#8221; so the cursor will not move to the next line; rather it will just stick at this position.&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;\">Now, let&#8217;s use the <\/span><b>scanf<\/b><span style=\"font-weight: 400;\"> function.&nbsp; Let&#8217;s first mention the format specifier &#8220;%f&#8221;; after that, let&#8217;s give a comma, and then give the address of the first variable number1. After that, let&#8217;s repeat these two statements for the second and third 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;\">After that, let&#8217;s compute the average. Then print the average. The code is shown below.<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"font-size: 12px; box-shadow: #cecece 0px 0px 0px 0px inset;\">#include &lt;stdio.h&gt;\r\n\r\nint main(void)\r\n{\r\n\r\nfloat number1, number2, number3;\r\nfloat average;\r\n\r\nprintf(\"Enter the first number: \");\r\nscanf(\"%f\",&amp;number1);\r\nprintf(\"\\nEnter the second number: \");\r\nscanf(\"%f\",&amp;number2);\r\nprintf(\"\\nEnter the third number: \");\r\nscanf(\"%f\",&amp;number3);\r\n\r\n\r\naverage = (number1 + number2 + number3) \/ 3;\r\n\r\nprintf(\"\\nAverage is : %f\\n\",average);\r\n\r\n}<\/pre>\n<p class=\"\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<figure id=\"attachment_10279\" aria-describedby=\"caption-attachment-10279\" style=\"width: 651px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10279 \" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/07\/Figure-5-7.png\" alt=\"Figure 5. Code\" width=\"651\" height=\"332\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-5-7.png 1685w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-5-7-300x153.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-5-7-1024x522.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-5-7-768x392.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-5-7-600x306.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-5-7-1536x783.png 1536w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-5-7-120x61.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-5-7-500x255.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-5-7-200x102.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-5-7-400x204.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-5-7-800x408.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-5-7-1200x612.png 1200w\" sizes=\"(max-width: 651px) 100vw, 651px\" \/><figcaption id=\"caption-attachment-10279\" class=\"wp-caption-text\">Figure 5. Code<\/figcaption><\/figure>\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;\">Then, let&#8217;s build this project. It was built successfully, and let&#8217;s run. Now we can see that(Figure 5) when you try to run the application, the Average.exe runs, but the first message is not getting printed. Now the reason for that is &#8220;Enter the first number&#8221; this message is not reaching the console. That means this message is actually buffered inside the operating system. So, that is not pushed or flushed to the console. So, problems like this you may encounter when you use a different console. Here we are using the Console of an eclipse software. So, there may be console buffering.<\/span><\/p>\n<p class=\"\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<figure id=\"attachment_10281\" aria-describedby=\"caption-attachment-10281\" style=\"width: 701px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10281 \" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/07\/Figure-6-6-1024x478.png\" alt=\"Figure 6. Relationship between printf, output buffer, and display\" width=\"701\" height=\"327\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-6-6-1024x478.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-6-6-300x140.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-6-6-768x358.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-6-6-600x280.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-6-6-1536x717.png 1536w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-6-6-120x56.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-6-6-500x233.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-6-6-200x93.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-6-6-400x187.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-6-6-800x373.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-6-6-1200x560.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-6-6.png 1729w\" sizes=\"(max-width: 701px) 100vw, 701px\" \/><figcaption id=\"caption-attachment-10281\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 6. Relationship between printf, output buffer, and display<\/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=\"color: #000000;\"><span style=\"font-weight: 400;\">When you execute printf, what happens is that the content will not be pushed directly to the Display. It is actually buffered inside the output buffer.<\/span> <span style=\"font-weight: 400;\">So, this is actually a software buffer.&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=\"font-weight: 400; color: #000000;\">When your application returns, the content of the output buffer will be automatically flushed to the display. But in our program what&#8217;s happening is, we are waiting for the user input. So, there is no trigger for the output buffer to flush the contents to the display. In the earlier program we were returning from the function. So, there was a trigger to flush the contents of the output buffer to the display. So now, here we have to give explicit command for the output buffer to flush the contents to the display.<\/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=\"color: #000000;\"><span style=\"font-weight: 400;\">Now we do that by using a function called <\/span><b>fflush<\/b><span style=\"font-weight: 400;\">. fflush is actually an API which is used to clear the output buffers of the output stream. When you use fflush, the contents of the output buffer will be flushed to the display.<\/span><span style=\"font-weight: 400;\">&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;\">Let&#8217;s use this fflush. Here, write after the printf statement. <\/span><b>fflush(stdout);<\/b><span style=\"font-weight: 400;\"> The argument you have to pass here is that stdout, which is standard output, is flush to the standard output.<\/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;\">Usage of fflush is to flush the contents of the output buffer to the stdout. Its usage also depends on the type of console you use. Here we are displaying on the console of \u2018eclipse\u2019 software. When you execute the .exe on windows command prompt, fflush may not be required.<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"font-size: 12px; box-shadow: #cecece 0px 0px 0px 0px;\">int main(void)\r\n{\r\n\r\nfloat number1, number2, number3;\r\nfloat average;\r\n\r\nprintf(\"Enter the first number: \");\r\n<span style=\"color: #ffff00;\">fflush(stdout);<\/span>\r\nscanf(\"%f\",&amp;number1);\r\nprintf(\"\\nEnter the second number: \");\r\n<span style=\"color: #ffff00;\">fflush(stdout);<\/span>\r\nscanf(\"%f\",&amp;number2);\r\nprintf(\"\\nEnter the third number: \");\r\n<span style=\"color: #ffff00;\">fflush(stdout);<\/span>\r\nscanf(\"%f\",&amp;number3);\r\n\r\n\r\naverage = (number1 + number2 + number3) \/ 3;\r\n\r\nprintf(\"\\nAverage is : %f\\n\",average);\r\n\r\n}<\/pre>\n<figure id=\"attachment_10285\" aria-describedby=\"caption-attachment-10285\" style=\"width: 704px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10285 \" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/07\/Figure-7-6-1024x496.png\" alt=\"Figure 7. Code\" width=\"704\" height=\"341\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-7-6-1024x496.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-7-6-300x145.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-7-6-768x372.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-7-6-600x290.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-7-6-1536x743.png 1536w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-7-6-120x58.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-7-6-500x242.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-7-6-200x97.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-7-6-400x194.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-7-6-800x387.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-7-6-1200x581.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-7-6.png 1709w\" sizes=\"(max-width: 704px) 100vw, 704px\" \/><figcaption id=\"caption-attachment-10285\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 7. Code<\/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\u2019s run this program. Now we are getting the message \u201cEnter the first number\u201d. Here, you can see that this eclipse console is not showing you the cursor(Figure 7). That&#8217;s a problem.<\/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 you can click here in the Console. Let me type the first number as 3.5, and let&#8217;s hit enter. Let me type the second number as 2.5 and enter the third number as 3. Let&#8217;s hit enter. And here you can see that it shows you the average result is 3, as shown in Figure 8. That is correct.&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;\">You can see that it is actually showing the cursor here. So, that is not correct.<\/span><\/p>\n<figure id=\"attachment_10286\" aria-describedby=\"caption-attachment-10286\" style=\"width: 700px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10286 \" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/07\/Figure-8-6-1024x632.png\" alt=\"Figure 8. Output\" width=\"700\" height=\"432\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-8-6-1024x632.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-8-6-300x185.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-8-6-768x474.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-8-6-600x370.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-8-6-120x74.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-8-6-500x309.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-8-6-200x123.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-8-6-400x247.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-8-6-800x494.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-8-6-1200x741.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-8-6.png 1291w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><figcaption id=\"caption-attachment-10286\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 8. Output<\/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;\">So, this eclipse console is not that great. Instead of using this, you can directly execute&nbsp; Average.exe as a windows application.&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;\">For that, you have to go to its path. Right-click on the project, and go to properties. And in the resource tab, you can see this icon(Show in System Explorer), just click that, and it will open the project workspace.<\/span><\/p>\n<figure id=\"attachment_10287\" aria-describedby=\"caption-attachment-10287\" style=\"width: 707px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10287 \" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/07\/Figure-9-5-1024x563.png\" alt=\"Figure 9. Properties of Average\" width=\"707\" height=\"389\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-9-5-1024x563.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-9-5-300x165.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-9-5-768x423.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-9-5-600x330.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-9-5-1536x845.png 1536w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-9-5-120x66.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-9-5-500x275.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-9-5-200x110.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-9-5-400x220.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-9-5-800x440.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-9-5-1200x660.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-9-5.png 1685w\" sizes=\"(max-width: 707px) 100vw, 707px\" \/><figcaption id=\"caption-attachment-10287\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 9. Properties of Average<\/span><\/figcaption><\/figure>\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;\">Go inside<\/span><b> Average<\/b><span style=\"font-weight: 400;\">, go inside <\/span><b>Debug<\/b><span style=\"font-weight: 400;\">, and you can directly launch this <\/span><b>Average.exe<\/b><span style=\"font-weight: 400;\">. <\/span><\/span><\/p>\n<figure id=\"attachment_10288\" aria-describedby=\"caption-attachment-10288\" style=\"width: 703px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10288 \" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/07\/Figure-10-4-1024x536.png\" alt=\"Figure 10. Average.exe\" width=\"703\" height=\"368\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-10-4-1024x536.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-10-4-300x157.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-10-4-768x402.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-10-4-600x314.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-10-4-120x63.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-10-4-500x262.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-10-4-200x105.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-10-4-400x209.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-10-4-800x419.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-10-4-1200x628.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-10-4.png 1355w\" sizes=\"(max-width: 703px) 100vw, 703px\" \/><figcaption id=\"caption-attachment-10288\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 10. Average.exe<\/span><\/figcaption><\/figure>\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 launch this application, just double click on Average.exe, and here you can see that this looks good because it is actually showing you the correct cursor position for you to enter the number.&nbsp;<\/span><\/p>\n<figure id=\"attachment_10289\" aria-describedby=\"caption-attachment-10289\" style=\"width: 534px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10289 \" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/07\/Figure-11-4-1024x555.png\" alt=\"Figure 11.Windows command prompt\" width=\"534\" height=\"290\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-11-4-1024x555.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-11-4-300x163.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-11-4-768x416.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-11-4-600x325.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-11-4-120x65.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-11-4-500x271.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-11-4-200x108.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-11-4-400x217.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-11-4-800x434.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-11-4-1200x650.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-11-4.png 1323w\" sizes=\"(max-width: 534px) 100vw, 534px\" \/><figcaption id=\"caption-attachment-10289\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 11.Windows command prompt<\/span><\/figcaption><\/figure>\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;\">Enter some numbers. Let me enter 45, 10, -9888&nbsp; and press enter. Here you can see that the console is exited(Figure 12). We couldn&#8217;t be able to see the result. <\/span><span style=\"font-weight: 400;\">&nbsp;<\/span><\/span><\/p>\n<figure id=\"attachment_10290\" aria-describedby=\"caption-attachment-10290\" style=\"width: 554px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10290 \" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/07\/Figure-12-4-1024x444.png\" alt=\"Figure 12. Console\" width=\"554\" height=\"240\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-12-4-1024x444.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-12-4-300x130.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-12-4-768x333.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-12-4-600x260.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-12-4-120x52.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-12-4-500x217.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-12-4-200x87.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-12-4-400x173.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-12-4-800x346.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-12-4-1200x520.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-12-4.png 1383w\" sizes=\"(max-width: 554px) 100vw, 554px\" \/><figcaption id=\"caption-attachment-10290\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 12. Console<\/span><\/figcaption><\/figure>\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;\">That&#8217;s because in the program after you print the average, this code exits. That&#8217;s actually the completion of the application. That&#8217;s why the console exited. So, we couldn&#8217;t be able to observe the result.&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;\">Let&#8217;s implement some logic in the program so that your program hangs after printing the result. For that, we can make the application wait until the user presses any key from the keyboard. That means let&#8217;s use getchar() here. So, let me use the getchar() API. This API waits until the user presses any key from the keyboard. Now let me just call getchar(). That means to get a character from the keyboard. So, until the user enters a character, this API waits. Let&#8217;s test this.<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"font-size: 12px; box-shadow: #cecece 0px 0px 0px 0px;\">int main(void)\r\n{\r\n\r\nfloat number1, number2, number3;\r\nfloat average;\r\n\r\nprintf(\"Enter the first number: \");\r\nfflush(stdout);\r\nscanf(\"%f\",&amp;number1);\r\nprintf(\"\\nEnter the second number: \");\r\nfflush(stdout);\r\nscanf(\"%f\",&amp;number2);\r\nprintf(\"\\nEnter the third number: \");\r\nfflush(stdout);\r\nscanf(\"%f\",&amp;number3);\r\n\r\n\r\naverage = (number1 + number2 + number3) \/ 3;\r\n\r\nprintf(\"\\nAverage is : %f\\n\",average);\r\n\r\n<span style=\"color: #ffff00;\">getchar();<\/span>\r\n}<\/pre>\n<p class=\"\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\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;\"><span style=\"color: #000000;\">Let&#8217;s see whether our application waits for the user input or not before it exits. Let me launch once again.&nbsp;<\/span> &nbsp; <\/span><\/p>\n<figure id=\"attachment_10293\" aria-describedby=\"caption-attachment-10293\" style=\"width: 611px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10293\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/07\/Figure-15-3.png\" alt=\"Scanf exercise implementation\" width=\"611\" height=\"330\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-15-3.png 969w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-15-3-300x162.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-15-3-768x415.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-15-3-600x324.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-15-3-120x65.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-15-3-500x270.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-15-3-200x108.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-15-3-400x216.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-15-3-800x432.png 800w\" sizes=\"(max-width: 611px) 100vw, 611px\" \/><figcaption id=\"caption-attachment-10293\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 13. Output<\/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;\">Now, it doesn&#8217;t wait, and again the console is exited. So now, we have to understand what exactly is going on here. So, it didn&#8217;t wait here.<\/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 understand the relationship between the keyboard, input buffer, and the program.<\/span><\/p>\n<figure id=\"attachment_10294\" aria-describedby=\"caption-attachment-10294\" style=\"width: 698px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10294\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/07\/Figure-16-2-1024x565.png\" alt=\"Scanf exercise implementation\" width=\"698\" height=\"385\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-16-2-1024x565.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-16-2-300x166.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-16-2-768x424.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-16-2-600x331.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-16-2-120x66.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-16-2-500x276.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-16-2-200x110.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-16-2-400x221.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-16-2-800x442.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-16-2-1200x662.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-16-2.png 1241w\" sizes=\"(max-width: 698px) 100vw, 698px\" \/><figcaption id=\"caption-attachment-10294\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 14. Relationship between the keyboard,input buffer,and the program<\/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=\"color: #000000;\"><b>a<\/b><span style=\"font-weight: 400;\">.<\/span> <span style=\"font-weight: 400;\">Now, whatever you enter from the keyboard, it doesn&#8217;t come to the program directly. It actually goes to the Input buffer.<\/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;\"><strong>b.<\/strong> For example, we are scanning for the first number. Let&#8217;s say you enter 10, and after that, you hit enter.<\/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;\"><strong>c.<\/strong> Once you do that at the keyboard side, those two data(10\\n) will come to the input buffer. Now the input buffer has two different data. One is a number that you enter, that is 10, and another one is the new line character, so that is your enter key, so that is also stored in the input buffer.<\/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;\">Once it comes to the input buffer, scanf actually reads the data. In this case, the scanf should read one real number. So, we want to read a real number. That&#8217;s why we specified the format specifier <\/span><b>%f<\/b><span style=\"font-weight: 400;\">. So,<\/span><b>10\\n<\/b><span style=\"font-weight: 400;\"> this data will be read from the scanf. So, we have instructed scanf just to read one data because there is only one format specifier.<\/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;\"><strong>d.<\/strong> Once scanf reads that, this will be the state of the input buffer. So now \\n is remaining in the input buffer. So, that is unread data.<\/span><\/p>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_10295\" aria-describedby=\"caption-attachment-10295\" style=\"width: 716px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10295\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/07\/Figure-17-1-1024x579.png\" alt=\"Scanf exercise implementation\" width=\"716\" height=\"405\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-17-1-1024x579.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-17-1-300x170.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-17-1-768x434.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-17-1-600x339.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-17-1-120x68.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-17-1-500x283.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-17-1-200x113.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-17-1-400x226.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-17-1-800x452.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-17-1-1200x678.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-17-1.png 1221w\" sizes=\"(max-width: 716px) 100vw, 716px\" \/><figcaption id=\"caption-attachment-10295\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 15. Relationship between keyboard, Input buffer, and the Program<\/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=\"\"><b><\/b><span style=\"color: #000000;\"><span style=\"font-weight: 400;\"><strong>e.<\/strong> After that, you want to execute the second scanf. Once you make a call to the second scanf, what happens? So, this <\/span><b>\\n<\/b><span style=\"font-weight: 400;\"> (that is a special character, the new line character) will be read and discarded by the scanf because it&#8217;s not a valid number but a special character. So, scanf waits for the new user input.&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=\"\"><b><\/b><span style=\"font-weight: 400; color: #000000;\"><strong>f.<\/strong> After that, let&#8217;s say the user enters a new number followed by the enter key. So, scanf will read this number 45.&nbsp;&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;\"><b>g.<\/b> <span style=\"font-weight: 400;\">And after that, you execute the final scanf for the number 3. This time the input buffer contains 65 and a new line character(\\n). So now, 65 will be read by the scanf. <\/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;\"><b>h.<\/b><span style=\"font-weight: 400;\"> After that, this is the final state of the input buffer after 3 scanf&#8217;s in the program. So, there is data which is still there in the input buffer.<\/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, what we are doing in the program is calculating the average, and then we are printing the average, and after that, we use getchar().<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_10296\" aria-describedby=\"caption-attachment-10296\" style=\"width: 599px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10296\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/07\/Figure-18-1-1024x508.png\" alt=\"Scanf exercise implementation\" width=\"599\" height=\"297\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-18-1-1024x508.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-18-1-300x149.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-18-1-768x381.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-18-1-600x297.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-18-1-1536x762.png 1536w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-18-1-120x59.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-18-1-500x248.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-18-1-200x99.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-18-1-400x198.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-18-1-800x397.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-18-1-1200x595.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-18-1.png 1789w\" sizes=\"(max-width: 599px) 100vw, 599px\" \/><figcaption id=\"caption-attachment-10296\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 16. Relationship between keyboard, Input buffer, and the Program<\/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;\">So, this time, getchar () doesn&#8217;t wait for the user input. Because getchar() goes and fetches whatever the data is there in the input buffer. So, getchar() fetches \\n and it returns. That&#8217;s the behavior of the getchar(). Whenever it encounters a new line character, the getchar() returns immediately. So, that is the behavior of that API. That&#8217;s why getchar() fetches \\n, and it returns. So, that&#8217;s why our application didn&#8217;t wait, so it exited immediately.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 20px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">How to solve this issue?<\/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;\">One thing is you can give getchar() twice here. So now, you can solve this problem by giving getchar() twice. This is actually not a generic solution, but just to see the effect. You can give getchar() twice here, and you can give one message to the user saying &#8220;press enter key to exit the application,&#8221; as shown in Figure 17.<\/span><\/p>\n<figure id=\"attachment_10297\" aria-describedby=\"caption-attachment-10297\" style=\"width: 703px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10297\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/07\/Figure-19-1-1024x488.png\" alt=\"Scanf exercise implementation\" width=\"703\" height=\"335\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-19-1-1024x488.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-19-1-300x143.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-19-1-768x366.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-19-1-600x286.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-19-1-1536x731.png 1536w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-19-1-120x57.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-19-1-500x238.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-19-1-200x95.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-19-1-400x190.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-19-1-800x381.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-19-1-1200x571.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-19-1.png 1913w\" sizes=\"(max-width: 703px) 100vw, 703px\" \/><figcaption id=\"caption-attachment-10297\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 17. Code<\/span><\/figcaption><\/figure>\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\u2019s try.<\/span><\/p>\n<figure id=\"attachment_10298\" aria-describedby=\"caption-attachment-10298\" style=\"width: 617px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10298\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/07\/Figure-20-1-1024x475.png\" alt=\"Scanf exercise implementation\" width=\"617\" height=\"286\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-20-1-1024x475.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-20-1-300x139.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-20-1-768x356.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-20-1-600x278.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-20-1-120x56.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-20-1-500x232.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-20-1-200x93.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-20-1-400x186.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-20-1-800x371.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-20-1-1200x557.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-20-1.png 1455w\" sizes=\"(max-width: 617px) 100vw, 617px\" \/><figcaption id=\"caption-attachment-10298\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 18. Output<\/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;\">Now here you can see that the application is waiting because of that second getchar(), and if you press the enter key, the getchar() immediately returns, and the application exited.<\/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;\">That is not a generic solution. I would use a while loop here. Don&#8217;t worry, I have not yet covered the while loop, so you will understand this code after I cover the looping in &#8216;C.&#8217;<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"font-size: 12px; box-shadow: #cecece 0px 0px 0px 0px inset;\">average = (number1 + number2 + number3) \/ 3;\r\n\r\nprintf(\"\\nAverage is : %f\\n\", average);\r\n\r\nprintf(\"Press enter key to exit the application \\n\");\r\n<span style=\"color: #ffff00;\">while(getchar() != '\\n')<\/span>\r\n{\r\n\r\n}\r\ngetchar();\r\n}<\/pre>\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;\">I write <\/span><b>while(getchar() != \u2018\\n\u2019)<\/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;\">I just loop here until I read every data from the input buffer. After that, at the end, I again wait for the user input, so give <\/span><b>getchar();&nbsp;<\/b><\/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\u2019s just test this.&nbsp;<\/span><\/p>\n<figure id=\"attachment_10300\" aria-describedby=\"caption-attachment-10300\" style=\"width: 662px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10300\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/07\/Figure-22-1-1024x399.png\" alt=\"Scanf exercise implementation\" width=\"662\" height=\"258\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-22-1-1024x399.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-22-1-300x117.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-22-1-768x299.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-22-1-600x234.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-22-1-120x47.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-22-1-500x195.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-22-1-200x78.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-22-1-400x156.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-22-1-800x311.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-22-1-1200x467.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-22-1.png 1487w\" sizes=\"(max-width: 662px) 100vw, 662px\" \/><figcaption id=\"caption-attachment-10300\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 22. Output<\/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;\">The average is shown in Figure 22. You can cross-check this with your calculator and then press enter key to exit the application.<\/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;\">In the following article, let&#8217;s use only one scanf to read all the 3 numbers instead of using three scanf functions.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 20px; line-height: 25px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><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;\"><span style=\"color: #000000;\">lick here:<\/span>&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; Scanf exercise implementation &nbsp; &nbsp; In this article, let&#8217;s do a scanf exercise. The exercise is, Write a program which takes 3 numbers from the user. And the program should compute the average of those numbers, and the result must be printed.&nbsp; &nbsp; Now let&#8217;s create a new project. Here we are creating a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":10296,"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-10272","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>Handling User Input and Calculating Averages Using scanf in C<\/title>\n<meta name=\"description\" content=\"scanf in c. Learn how to use the scanf function in C to calculate the average of three numbers. Understand the challenges of input buffering\" \/>\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-lecture-66-scanf-exercise-implementation\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Handling User Input and Calculating Averages Using scanf in C\" \/>\n<meta property=\"og:description\" content=\"scanf in c. Learn how to use the scanf function in C to calculate the average of three numbers. Understand the challenges of input buffering\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation\/\" \/>\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-07-09T06:28:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-26T09:06:59+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-18-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1789\" \/>\n\t<meta property=\"og:image:height\" content=\"887\" \/>\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=\"13 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-lecture-66-scanf-exercise-implementation\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation\\\/\"},\"author\":{\"name\":\"FastBitLab\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\"},\"headline\":\"Microcontroller Embedded C Programming Lecture 66| Scanf exercise implementation\",\"datePublished\":\"2022-07-09T06:28:58+00:00\",\"dateModified\":\"2023-08-26T09:06:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation\\\/\"},\"wordCount\":2023,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/Figure-18-1.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-lecture-66-scanf-exercise-implementation\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation\\\/\",\"name\":\"Handling User Input and Calculating Averages Using scanf in C\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/Figure-18-1.png\",\"datePublished\":\"2022-07-09T06:28:58+00:00\",\"dateModified\":\"2023-08-26T09:06:59+00:00\",\"description\":\"scanf in c. Learn how to use the scanf function in C to calculate the average of three numbers. Understand the challenges of input buffering\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation\\\/#primaryimage\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/Figure-18-1.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/Figure-18-1.png\",\"width\":1789,\"height\":887,\"caption\":\"Figure 18. Relationship between keyboard, Input buffer, and the Program\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Microcontroller Embedded C Programming Lecture 66| Scanf exercise implementation\"}]},{\"@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":"Handling User Input and Calculating Averages Using scanf in C","description":"scanf in c. Learn how to use the scanf function in C to calculate the average of three numbers. Understand the challenges of input buffering","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-lecture-66-scanf-exercise-implementation\/","og_locale":"en_US","og_type":"article","og_title":"Handling User Input and Calculating Averages Using scanf in C","og_description":"scanf in c. Learn how to use the scanf function in C to calculate the average of three numbers. Understand the challenges of input buffering","og_url":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation\/","og_site_name":"FastBit EBA","article_publisher":"https:\/\/www.facebook.com\/fastbiteba\/","article_published_time":"2022-07-09T06:28:58+00:00","article_modified_time":"2023-08-26T09:06:59+00:00","og_image":[{"width":1789,"height":887,"url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-18-1.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":"13 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation\/#article","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation\/"},"author":{"name":"FastBitLab","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d"},"headline":"Microcontroller Embedded C Programming Lecture 66| Scanf exercise implementation","datePublished":"2022-07-09T06:28:58+00:00","dateModified":"2023-08-26T09:06:59+00:00","mainEntityOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation\/"},"wordCount":2023,"commentCount":0,"publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-18-1.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-lecture-66-scanf-exercise-implementation\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation\/","url":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation\/","name":"Handling User Input and Calculating Averages Using scanf in C","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation\/#primaryimage"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-18-1.png","datePublished":"2022-07-09T06:28:58+00:00","dateModified":"2023-08-26T09:06:59+00:00","description":"scanf in c. Learn how to use the scanf function in C to calculate the average of three numbers. Understand the challenges of input buffering","breadcrumb":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation\/#primaryimage","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-18-1.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/07\/Figure-18-1.png","width":1789,"height":887,"caption":"Figure 18. Relationship between keyboard, Input buffer, and the Program"},{"@type":"BreadcrumbList","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-66-scanf-exercise-implementation\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fastbitlab.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Microcontroller Embedded C Programming Lecture 66| Scanf exercise implementation"}]},{"@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\/10272","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=10272"}],"version-history":[{"count":5,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/10272\/revisions"}],"predecessor-version":[{"id":15229,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/10272\/revisions\/15229"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media\/10296"}],"wp:attachment":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media?parent=10272"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/categories?post=10272"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/tags?post=10272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}