From fa0dc68a4663128b9e8befe846e22cba3f41b6af Mon Sep 17 00:00:00 2001 From: Brandon Rodriguez <brodriguez8774@gmail.com> Date: Thu, 23 Jan 2020 02:07:05 -0500 Subject: [PATCH] Implement "Problem 6" --- main.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index c343bab..bf362bb 100644 --- a/main.c +++ b/main.c @@ -168,13 +168,36 @@ void problem_5() { /** * Problem 6 * - * + * Declare a float of "1e20". + * Print to console. + * Declare a float of "(1e20 + 3500000000)". + * Print to console. + * Declare a float of "(1e20 + (3500000000 * 1000000000))". + * Print to console. + * Declare a float of "1e20". + * Using a loop, add 3500000000 to the float, 1000000000 different times. + * Print to console. */ void problem_6() { printf("\n\nProblem 6 start.\n\n"); printf("Expected Output:\n"); - printf("\n"); + printf("100000002004087734272\n"); + printf("100000002007587734272\n"); + printf("103500002052240572416\n"); + printf("103500002052240572416\n"); printf("Actual Output:\n"); + float test_float = 1e20; + printf("%.10lf\n", test_float); + test_float = (1e20 + 3500000000); + printf("%.10lf\n", test_float); + test_float = (1e20 + (3500000000 * 1000000000)); + printf("%.10lf\n", test_float); + test_float = 1e20; + for (int index = 0; index < 1000000000; index++) { + test_float += 3500000000; + } + printf("%.10lf\n", test_float); + printf("\nProblem 6 end.\n"); } -- GitLab