{"id":9407,"date":"2022-04-29T04:00:18","date_gmt":"2022-04-29T04:00:18","guid":{"rendered":"http:\/\/fastbitlab.com\/?p=9407"},"modified":"2023-01-20T12:31:39","modified_gmt":"2023-01-20T07:01:39","slug":"microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution","status":"publish","type":"post","link":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution\/","title":{"rendered":"Microcontroller Embedded C Programming Lecture 20| Printf exercise solution"},"content":{"rendered":"<div class=\"boldgrid-section color4-background-color color-4-text-contrast bg-background-color\" style=\"padding: 0px 5px;\">\n<div class=\"container\">\n<div class=\"row\" style=\"padding-top: 10px;\">\n<div class=\"col-lg-12 col-md-1 col-sm-12 col-xs-12\" style=\"padding-left: 40px;\"><\/div>\n<div class=\"col-lg-12 col-md-10 col-xs-12 col-sm-12\" style=\"padding: 0px 6em;\">\n<h1 class=\"\" style=\"text-align: center; padding: 0px; border-width: 0px; font-size: 35px; line-height: 50px; 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: #000080;\">Printf exercise solution<\/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=\"\">&nbsp;<\/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;\">In this article, we do some exercises.&nbsp; Write a program to print the below text using the printf function.<\/span><\/p>\n<p class=\"\"><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter wp-image-9410 size-full\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/04\/Figure.png\" alt=\"\" width=\"1285\" height=\"429\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure.png 1285w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-300x100.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-1024x342.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-768x256.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-600x200.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-120x40.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-500x167.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-200x67.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-400x134.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-800x267.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-1200x401.png 1200w\" sizes=\"(max-width: 1285px) 100vw, 1285px\" \/><\/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;\">Remember that the output should exactly look something like this. And you should maintain all the punctuation, special characters, everything you have to maintain exactly shown in this text message. So, you can either use a single printf function or multiple printf functions. So, you can do it whichever way you want, no problem with that.<\/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 data-preserver-spaces=\"true\">Let\u2019s do that. Now, let me first use printf for each and every line. Let me write&nbsp;<\/span><strong><span data-preserver-spaces=\"true\">printf<\/span><\/strong><span data-preserver-spaces=\"true\">&nbsp;and open the bracket and write the given text. In printf, you have to write your message in double-quotes, close the bracket, and give the semicolon. Complete this step for every line.<\/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;\">The solution is given in Figure 1.&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 aria-level=\"1\"><b>David says, \u201cprogramming is fun!\u201d<\/b><\/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;\">In the first statement, we are printing double-quotes. So, we put a <span style=\"color: #ff0000;\">backslash escape character(\\) <\/span>before the double quote. We did it in a previous article. And let&#8217;s use <span style=\"color: #ff0000;\">\\n<\/span> to go to the new line.<\/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=\"\"><b>printf(\u201cDavid says, \\\u201cprogramming is fun !\\\u201d, \\n\u201d);<\/b><\/p>\n<p class=\"\">&nbsp;<\/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 aria-level=\"1\"><b>**Conditions apply, \u201cOffers valid until tomorrow\u201d<\/b><\/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;\">Here, also give the <span style=\"color: #ff0000;\">backslash escape character(\\)<\/span> before the double quote. Let&#8217;s use <span style=\"color: #ff0000;\">\\n<\/span> here as well.<\/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=\"\"><b>printf(\u201c**Conditions apply, \\\u201cOffers valid until tomorrow\\\u201d\\n\u201d);<\/b><\/p>\n<p class=\"\">&nbsp;<\/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\"><b>C:\\My computer\\My folder<\/b><\/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;\">In this example, there is one backslash escape character before the M character. So, this is considered as <\/span><b>\\M<\/b><span style=\"font-weight: 400;\">. <\/span><b>\\M <\/b><span style=\"font-weight: 400;\">is not a valid escape sequence. If you want to print that backslash, you can use <strong><span style=\"color: #ff0000;\">\\\\<\/span><\/strong><\/span> <span style=\"font-weight: 400;\">escape sequence.&nbsp;&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=\"\"><b>printf(\u201cC:\\\\My computer\\\\My folder\\n\u201d);<\/b><\/p>\n<p class=\"\">&nbsp;<\/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\"><b>D:\/My documents\/My file<\/b><\/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;\">This string is fine, no problem. Let&#8217;s use <span style=\"color: #ff0000;\">\\n<\/span> here.<\/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=\"\"><b>printf(\u201cD:\/My documents\/My file\\n\u201d);<\/b><\/p>\n<p class=\"\">&nbsp;<\/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\"><b>\\\\\\\\ Today is holiday\\\\\\\\<\/b><\/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;\">In this example, here we are printing backslash. That&#8217;s why we have to use the escape character that is <span style=\"color: #ff0000;\">backslash(\\)<\/span> for each and every backslash which we want to print and, in the end, give <span style=\"color: #ff0000;\">\\n<\/span>.&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=\"\"><b>printf(\u201c \\\\ \\\\ \\\\ \\\\ Today is holiday \\\\ \\\\ \\\\ \\\\\\n\u201d);<\/b><\/p>\n<p class=\"\">&nbsp;<\/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\"><b>This is a triple quoted string &#8220;&#8221;&#8221; This month has 30 days &#8220;&#8221;&#8221;<\/b><\/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;\">In this example, there is a triple quoted string, and here there are multiple double quotes, so we have to use <span style=\"color: #ff0000;\">backslash<\/span> for every double quote here. And after that at the end <span style=\"color: #ff0000;\">\\n<\/span>.&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=\"\"><b>printf(\u201cThis is a triple quoted string \\&#8221;\\&#8221;\\&#8221; This month has 30 days \\&#8221;\\&#8221;\\&#8221;\\n\u201d);<\/b><\/p>\n<figure id=\"attachment_9412\" aria-describedby=\"caption-attachment-9412\" style=\"width: 1611px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-9412 size-full\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/04\/Figure-1-28.png\" alt=\"Figure 1. Solution of printf exercise\" width=\"1611\" height=\"681\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-1-28.png 1611w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-1-28-300x127.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-1-28-1024x433.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-1-28-768x325.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-1-28-600x254.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-1-28-1536x649.png 1536w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-1-28-120x51.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-1-28-500x211.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-1-28-200x85.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-1-28-400x169.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-1-28-800x338.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-1-28-1200x507.png 1200w\" sizes=\"(max-width: 1611px) 100vw, 1611px\" \/><figcaption id=\"caption-attachment-9412\" class=\"wp-caption-text\">Figure 1. Solution of printf exercise<\/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;\">Now this resolves all the issues. Let&#8217;s run this program. Here we got the correct output (Shown in Figure 2), so we got exactly the way we wanted.<\/span><\/p>\n<figure id=\"attachment_9413\" aria-describedby=\"caption-attachment-9413\" style=\"width: 724px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-9413 size-full\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/04\/Figure-2-22.png\" alt=\"Figure 2. Output\" width=\"724\" height=\"355\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-2-22.png 724w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-2-22-300x147.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-2-22-600x294.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-2-22-120x59.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-2-22-500x245.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-2-22-200x98.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-2-22-400x196.png 400w\" sizes=\"(max-width: 724px) 100vw, 724px\" \/><figcaption id=\"caption-attachment-9413\" class=\"wp-caption-text\">Figure 2. Output<\/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;\">If you are confused, just spend some time with the code and try to understand the syntaxes.<\/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;\">Click here:<\/span>&nbsp;<span style=\"color: #0000ff;\"><a style=\"color: #0000ff; text-decoration: underline;\" href=\"http:\/\/fastbitlab.com\/course1\">https:\/\/fastbitlab.com\/course1<\/a><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<\/div>\n<div class=\"col-lg-12 col-md-1 col-sm-12 col-xs-12\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Printf exercise solution &nbsp; &nbsp; &nbsp; In this article, we do some exercises.&nbsp; Write a program to print the below text using the printf function. Remember that the output should exactly look something like this. And you should maintain all the punctuation, special characters, everything you have to maintain exactly shown in this text message. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":9412,"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-9407","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>Printf in C - Exercise &amp; Solution | FastBit Embedded Brain Academy<\/title>\n<meta name=\"description\" content=\"Printf in C. In printf, write\u00a0printf\u00a0and open the bracket and write the given text in double-quotes, close the bracket, give the semicolon.\" \/>\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-20-printf-exercise-solution\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Printf in C - Exercise &amp; Solution | FastBit Embedded Brain Academy\" \/>\n<meta property=\"og:description\" content=\"Printf in C. In printf, write\u00a0printf\u00a0and open the bracket and write the given text in double-quotes, close the bracket, give the semicolon.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution\/\" \/>\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-04-29T04:00:18+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-20T07:01:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-1-28.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1611\" \/>\n\t<meta property=\"og:image:height\" content=\"681\" \/>\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=\"3 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-20-printf-exercise-solution\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution\\\/\"},\"author\":{\"name\":\"FastBitLab\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\"},\"headline\":\"Microcontroller Embedded C Programming Lecture 20| Printf exercise solution\",\"datePublished\":\"2022-04-29T04:00:18+00:00\",\"dateModified\":\"2023-01-20T07:01:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution\\\/\"},\"wordCount\":498,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/04\\\/Figure-1-28.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-20-printf-exercise-solution\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution\\\/\",\"name\":\"Printf in C - Exercise & Solution | FastBit Embedded Brain Academy\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/04\\\/Figure-1-28.png\",\"datePublished\":\"2022-04-29T04:00:18+00:00\",\"dateModified\":\"2023-01-20T07:01:39+00:00\",\"description\":\"Printf in C. In printf, write\u00a0printf\u00a0and open the bracket and write the given text in double-quotes, close the bracket, give the semicolon.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution\\\/#primaryimage\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/04\\\/Figure-1-28.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/04\\\/Figure-1-28.png\",\"width\":1611,\"height\":681,\"caption\":\"Figure 1. Solution of printf exercise\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Microcontroller Embedded C Programming Lecture 20| Printf exercise solution\"}]},{\"@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":"Printf in C - Exercise & Solution | FastBit Embedded Brain Academy","description":"Printf in C. In printf, write\u00a0printf\u00a0and open the bracket and write the given text in double-quotes, close the bracket, give the semicolon.","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-20-printf-exercise-solution\/","og_locale":"en_US","og_type":"article","og_title":"Printf in C - Exercise & Solution | FastBit Embedded Brain Academy","og_description":"Printf in C. In printf, write\u00a0printf\u00a0and open the bracket and write the given text in double-quotes, close the bracket, give the semicolon.","og_url":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution\/","og_site_name":"FastBit EBA","article_publisher":"https:\/\/www.facebook.com\/fastbiteba\/","article_published_time":"2022-04-29T04:00:18+00:00","article_modified_time":"2023-01-20T07:01:39+00:00","og_image":[{"width":1611,"height":681,"url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-1-28.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":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution\/#article","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution\/"},"author":{"name":"FastBitLab","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d"},"headline":"Microcontroller Embedded C Programming Lecture 20| Printf exercise solution","datePublished":"2022-04-29T04:00:18+00:00","dateModified":"2023-01-20T07:01:39+00:00","mainEntityOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution\/"},"wordCount":498,"commentCount":0,"publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-1-28.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-20-printf-exercise-solution\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution\/","url":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution\/","name":"Printf in C - Exercise & Solution | FastBit Embedded Brain Academy","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution\/#primaryimage"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-1-28.png","datePublished":"2022-04-29T04:00:18+00:00","dateModified":"2023-01-20T07:01:39+00:00","description":"Printf in C. In printf, write\u00a0printf\u00a0and open the bracket and write the given text in double-quotes, close the bracket, give the semicolon.","breadcrumb":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution\/#primaryimage","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-1-28.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/04\/Figure-1-28.png","width":1611,"height":681,"caption":"Figure 1. Solution of printf exercise"},{"@type":"BreadcrumbList","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-20-printf-exercise-solution\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fastbitlab.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Microcontroller Embedded C Programming Lecture 20| Printf exercise solution"}]},{"@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\/9407","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=9407"}],"version-history":[{"count":5,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/9407\/revisions"}],"predecessor-version":[{"id":12993,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/9407\/revisions\/12993"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media\/9412"}],"wp:attachment":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media?parent=9407"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/categories?post=9407"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/tags?post=9407"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}