CPPForSchool.com: Flow of Control Set 2: Assignment 1
1.
Write a program to print number from 1 to 10.
This program seems rather simple. My approach to this assignment will be to utilize a loop function. Prior to this assignment, I have not attempted any loops. In fact, most of my programs use conditional statements, specifically if/else conditions/statements. For my first loop assignment, I will use a while loop.
In order to become more comfortable with loops, I have also re-coded the assignment using a for loop.
**Notice that the for loop executed the same task .010 seconds faster. Although this is a minor improvement, perhaps in large scale programs, for loops will have a greater sense of efficiency.**
This program seems rather simple. My approach to this assignment will be to utilize a loop function. Prior to this assignment, I have not attempted any loops. In fact, most of my programs use conditional statements, specifically if/else conditions/statements. For my first loop assignment, I will use a while loop.
In order to become more comfortable with loops, I have also re-coded the assignment using a for loop.
**Notice that the for loop executed the same task .010 seconds faster. Although this is a minor improvement, perhaps in large scale programs, for loops will have a greater sense of efficiency.**
Comments
Post a Comment