{"id":38,"date":"2021-09-16T11:21:52","date_gmt":"2021-09-16T11:21:52","guid":{"rendered":"https:\/\/ethosspace.com\/programmers\/?p=38"},"modified":"2022-01-03T09:56:44","modified_gmt":"2022-01-03T09:56:44","slug":"c-program-to-calculate-acceleration-final-velocity-speed","status":"publish","type":"post","link":"https:\/\/ethosspace.com\/programmers\/c-program-to-calculate-acceleration-final-velocity-speed\/","title":{"rendered":"C Program to Calculate final velocity."},"content":{"rendered":"\n<p>Below Running code will calculate the final velocity based on user input.<\/p>\n\n\n\n<p>Program is using formula v = u + at. The assumption is the user will enter values in decimal and time should not be negative.<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/Program Name: Calculate Final Velocity.\n\/\/formula v= u + at \n\/\/u = initial velocity\n\/\/v = final velocity\n\/\/a = acceleration\n\/\/t = time\n\n#include&lt;stdio.h&gt;\nvoid main(){\n\n \/\/declare variable\n float u,t, a, v;\n\n \/\/get value of initial velocity\n printf(\"Enter the Value Of Initial Velocity  \");\n scanf(\"%f\",&amp;u);\n\n \/\/read value of time\n printf(\"Enter the Value Of Time  \");\n scanf(\"%f\",&amp;t);\n\n \/\/Read value of acceleration\n printf(\"Enter the Value Of acceleration  \");\n scanf(\"%f\",&amp;a);\n\n\/\/Calculate only if time is not negative\n if( t &gt; 0 ) \n {\n \/\/ formula to calculate final velocity\n v = ( u + ( a * t ) );\n printf(\"With the initial velocity %.2f, time %.2f and acceleration %.2f, \\n The value of final velocity is %f m\/s\", u, t, a, v);\n }\n else\n {\n printf(\"Entered time is negative\");\n } \n}<\/code><\/pre>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<div class=\"wp-block-columns has-white-color has-cyan-bluish-gray-background-color has-text-color has-background is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>Enter the Value Of Initial Velocity 27<br>Enter the Value Of Time 3<br>Enter the Value Of acceleration 2<br>With the initial velocity 27.00, time 3.00 and acceleration 2.00,<br>The value of final velocity is 33.000000 m\/s<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Enter the Value Of Initial Velocity 27<br>Enter the Value Of Time 0<br>Enter the Value Of acceleration 2<br>Entered time is negative<\/p>\n<\/div>\n<\/div>\n\n\n\n<p>Users can enter velocity-time and acceleration in decimal values so we declare variables as a float. The program also shows how to display decimal points up to 2 digits by using %.2f<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Below Running code will calculate the final velocity based on user input. Program is using formula v = u + at. The assumption is the user will enter values in decimal and time should not be negative. Output Enter the Value Of Initial Velocity 27Enter the Value Of Time 3Enter the Value Of acceleration 2With [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[6],"tags":[],"class_list":["post-38","post","type-post","status-publish","format-standard","hentry","category-c-language"],"aioseo_notices":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"sparkling-featured":false,"sparkling-featured-fullwidth":false,"tab-small":false},"uagb_author_info":{"display_name":"program45_-rt8nb","author_link":"https:\/\/ethosspace.com\/programmers\/author\/program45_-rt8nb\/"},"uagb_comment_info":0,"uagb_excerpt":"Below Running code will calculate the final velocity based on user input. Program is using formula v = u + at. The assumption is the user will enter values in decimal and time should not be negative. Output Enter the Value Of Initial Velocity 27Enter the Value Of Time 3Enter the Value Of acceleration 2With&hellip;","_links":{"self":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/38","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/comments?post=38"}],"version-history":[{"count":10,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/38\/revisions"}],"predecessor-version":[{"id":1215,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/38\/revisions\/1215"}],"wp:attachment":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/media?parent=38"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/categories?post=38"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/tags?post=38"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}