{"id":799,"date":"2017-08-13T16:18:47","date_gmt":"2017-08-13T16:18:47","guid":{"rendered":"http:\/\/people.utm.my\/kohmenghock\/?page_id=799"},"modified":"2017-08-13T16:27:19","modified_gmt":"2017-08-13T16:27:19","slug":"codeblocks-simple-guide-formatted-print-statement","status":"publish","type":"page","link":"https:\/\/people.utm.my\/kohmenghock\/codeblocks-simple-guide-requesting-input-from-user\/codeblocks-simple-guide-formatted-print-statement\/","title":{"rendered":"Code::Blocks simple guide &#8211; formatted print statement"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><span style=\"font-size: 12pt;font-family: arial,helvetica,sans-serif\">I will discuss on formatted print statement here using the example below:<br \/>\n<\/span><\/p>\n<p><a href=\"https:\/\/people.utm.my\/kohmenghock\/wp-content\/uploads\/sites\/982\/2017\/08\/formatted_print_statement.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-800 size-full\" src=\"https:\/\/people.utm.my\/kohmenghock\/wp-content\/uploads\/sites\/982\/2017\/08\/formatted_print_statement.png\" alt=\"\" width=\"765\" height=\"119\" srcset=\"https:\/\/people.utm.my\/kohmenghock\/wp-content\/uploads\/sites\/982\/2017\/08\/formatted_print_statement.png 765w, https:\/\/people.utm.my\/kohmenghock\/wp-content\/uploads\/sites\/982\/2017\/08\/formatted_print_statement-300x47.png 300w\" sizes=\"auto, (max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px\" \/><\/a><\/p>\n<p style=\"text-align: justify\"><span style=\"font-size: 12pt;font-family: arial,helvetica,sans-serif\"><br \/>\nThe first line &#8220;print* &#8221; is meant to simply create an empty line. Next we have a print statement whereby the number &#8220;101&#8221; provide a unique identity to the format that we will specify below.<br \/>\n<\/span><\/p>\n<p style=\"text-align: justify\"><span style=\"font-size: 12pt;font-family: arial,helvetica,sans-serif\"><br \/>\nThere are three parts (or items) to be printed. The first is a series of characters i.e. the line &#8220;The momentum of the object is&#8221;. The second is a variable &#8220;momentum&#8221; in which the value is obtained from calculation, and finally another series of characters.<br \/>\n<\/span><\/p>\n<p style=\"text-align: justify\"><span style=\"font-size: 12pt;font-family: arial,helvetica,sans-serif\"><br \/>\nNow when referring to the next line which specifies the format of the print statement, we see that characters are associated with the alphabet &#8220;a&#8221;. Next is the format for the variable. The variable &#8220;momentum&#8221; here is a real data type. Therefore, the format for the print statement of this variable starts with &#8220;<span style=\"color: #00ccff\">F<\/span>&#8221; or &#8220;<span style=\"color: #00ccff\">f<\/span>&#8220;. The first number following it (here it being 6) specifies the amount of digits plus decimal mark that we want in the value to be printed. The number after the decimal mark (here 3) specifies the number of decimal points. \u00a0For a more illustrative example, let us consider the result after taking 3 divided by 2.<br \/>\n<\/span><\/p>\n<p style=\"text-align: justify\"><span style=\"font-size: 12pt;font-family: arial,helvetica,sans-serif\"><br \/>\nIf we choose a format of <span style=\"color: #ff0000\"><strong>F6.4<\/strong><\/span>, we will have<\/span><\/p>\n<p style=\"text-align: center\"><span style=\"font-size: 12pt;font-family: arial,helvetica,sans-serif\"><strong>1.5000<\/strong><\/span><\/p>\n<p><span style=\"font-size: 12pt;font-family: arial,helvetica,sans-serif\"><br \/>\nand with <strong><span style=\"font-size: 12pt;font-family: arial,helvetica,sans-serif\"><span style=\"color: #ff0000\">F6.3<\/span> <\/span><\/strong>we get<\/span><\/p>\n<p style=\"text-align: center\"><span style=\"font-size: 12pt;font-family: arial,helvetica,sans-serif\"><strong>1.500<\/strong><\/span><\/p>\n<p><span style=\"font-size: 12pt;font-family: arial,helvetica,sans-serif\"><br \/>\nand finally with <strong><span style=\"color: #ff0000\">F3.1<\/span><\/strong>, we will have<\/span><\/p>\n<p style=\"text-align: center\"><span style=\"font-size: 12pt;font-family: arial,helvetica,sans-serif\"><strong>1.5<\/strong><\/span><\/p>\n<p style=\"text-align: left\"><span style=\"font-size: 12pt;font-family: arial,helvetica,sans-serif\">When printing integers, the same concept applies except that the starting alphabet is now &#8220;<span style=\"color: #00ccff\">I<\/span>&#8221; or &#8220;<span style=\"color: #00ccff\">i<\/span>&#8220;. Here are examples for the print format for integers:<\/span><\/p>\n<p style=\"text-align: center\"><span style=\"font-size: 12pt;font-family: arial,helvetica,sans-serif\"><strong>1000 &#8211; I4<\/strong><\/span><\/p>\n<p style=\"text-align: center\"><span style=\"font-size: 12pt;font-family: arial,helvetica,sans-serif\"><strong>200 &#8211; I3<\/strong><\/span><\/p>\n<p style=\"text-align: center\"><span style=\"font-size: 12pt;font-family: arial,helvetica,sans-serif\"><strong>10 &#8211; I2<\/strong><\/span><\/p>\n<p><span style=\"font-size: 12pt;font-family: arial,helvetica,sans-serif\"><br \/>\nFinally, a last remark is with regards to the symbol &#8220;<span style=\"color: #ff0000\">1x<\/span>&#8221; in the print statement above. This is used to create one empty (horizontal) space. You may use other numbers followed by &#8220;x&#8221; to create larger empty spaces.<br \/>\n<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; I will discuss on formatted print statement here using the example below: The first line &#8220;print* &#8221; is meant to simply create an empty line. Next we have a print statement whereby the number &#8220;101&#8221; provide a unique identity to the format that we will specify below. There are three parts (or items) to &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/people.utm.my\/kohmenghock\/codeblocks-simple-guide-requesting-input-from-user\/codeblocks-simple-guide-formatted-print-statement\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Code::Blocks simple guide &#8211; formatted print statement&#8221;<\/span><\/a><\/p>\n","protected":false},"author":14180,"featured_media":0,"parent":781,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-799","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/people.utm.my\/kohmenghock\/wp-json\/wp\/v2\/pages\/799","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/people.utm.my\/kohmenghock\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/people.utm.my\/kohmenghock\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/people.utm.my\/kohmenghock\/wp-json\/wp\/v2\/users\/14180"}],"replies":[{"embeddable":true,"href":"https:\/\/people.utm.my\/kohmenghock\/wp-json\/wp\/v2\/comments?post=799"}],"version-history":[{"count":0,"href":"https:\/\/people.utm.my\/kohmenghock\/wp-json\/wp\/v2\/pages\/799\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/people.utm.my\/kohmenghock\/wp-json\/wp\/v2\/pages\/781"}],"wp:attachment":[{"href":"https:\/\/people.utm.my\/kohmenghock\/wp-json\/wp\/v2\/media?parent=799"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}