Unit 3


  • Print
  • Loops and Arrays Introduction Many problems can be solved by carrying out a sequence of steps repetitively. The computer’s ability to carry out repetitive operations quickly is one of its strengths. In this unit you will learn about the looping constructs available to the C programmer. In addition to loops, this unit also covers a data structure called an array. Objectives To successfully complete this learning unit, you will be expected to:
    1. Demonstrate the ability to reuse code by using basic looping constructs.
    2. Use an array to store and retrieve data in memory.
    3. Break a problem down into logical steps.
    4. Handle input and output properly in the terminal window.

  • Learning Activities Collapse All
  • Toggle Drawer [u03s1] Unit 3 Study 1 Studies Use your C Programming: Absolute Beginners Guide text to read the following:
    • Chapter 14, “Code Repeat–Using Loops to Save Time and Effort,” pages 123–129.
    • Chapter 15, “Looking for Another Way to Create Loops,” pages 131–140.
    • Chapter 16, “Breaking In and Out of Looped Code,” pages 141–147.
    • Chapter 20 (part), “Advanced Math (For the Computer, Not You),” pages 187–191.
    • Chapter 21, “Dealing With Arrays,” pages 193–200.
    • Chapter 22, “Searching Arrays,” pages 201–208.
    • In Chapter 20, read the section “Getting Random” on the pages indicated.
    Use your Programming in C text to read the following:
    • Chapter 4, “Program Looping,” pages 43–64.
    • Chapter 6, “Working With Arrays,” pages 95–118.
    Optional Skillsoft Resources
    • Skillsoft. (n.d.). Software programming fundamentals: Design and development best practices [Tutorial].
    • Skillsoft. (n.d.). Agile planning: Project initiating and requirements gathering [Tutorial].
  • Toggle Drawer [u03d1] Unit 3 Discussion 1 Planning the Logic of the Program With a Loop Before starting to write code, it is important to have a clear picture of what the program should do and the steps in the process for reaching the desired result. Choose either the program for part 2 or part 3 of this unit’s assignment and write out, in plain English, what the program needs to do and describe the steps in the process to solve the problem. Focus on a clear explanation of the process of solving the problem, not writing C. While it is a good idea to do this for both programs, you only need to discuss one in this post. You should also discuss the type of loop you plan to use for your program and why. What role does the loop play in the program? Please focus on communicating in writing that is professional in tone and free of spelling and grammatical errors. Complete your initial post by Wednesday, 12:00 midnight Central Time. Response Guidelines Prior to Sunday evening, read and provide high-quality replies to at least two of your peers’ posts. In a constructive manner, point out areas of concern or of note. Include an example from your personal experience or reasoning, if applicable. Resources
    • Discussion Participation Scoring Guide.
    • Critical Thinking Resources.
  • Toggle Drawer [u03a1] Unit 3 Assignment 1 Programming in C: Unit 3 Exercises Part 1: Commenting Code Enter the code provided in the assignment Resources in CodeBlocks, compile, and run. Pay attention to the formatting of the code. Add at least eight comments to explain what the program does and how it works. Be sure to include a comment at the top of the file as a header like the one used in Unit 1. After adding your comments, build and test the program to make sure it still builds and runs correctly. Part 2: Guessing Game This program is a guessing game that counts how many tries it takes for a player to guess a random number in the range from 1 to 20 (inclusive) that the computer has generated. The program should prompt the user for a guess and then indicate if the guess was too high, too low, or correct. When the player guesses correctly, the program should print out how many guesses the player made. Your C code must be both well-formatted and well-commented. Be sure to include extended comments about the loop used in your code. Part 3: Simple Grade Book This program should use an array to store percentage grades in the range from 0 to 100 (inclusive). The program should allow the user to indicate when he or she is done entering grades. When the user is done entering grades, the program should print out the grades entered. Your C code must be both well-formatted and well-commented. Be sure to include extended comments about the loop used in your code. When you submit your assignment, please be sure to include the .c source code files for all three programs. Resources
    • Programming in C: Unit 3 Exercises Scoring Guide.
    • Unit 3 Part 1 Code for Commenting
  • Toggle Drawer Updates and Handouts Periodically, information will be posted in this space for the good of the class.
  • Toggle Drawer Ask Your Instructor This forum was created to provide a convenient space for you to ask questions—questions about particular assignment and discussion activities, questions about the course in general, questions about expectations. If there is something that you feel you could use help with, please post your question here. Most likely, some of your classmates will have the same concern, so your post may help several learners. If you feel your question is private, please use the Messages tool found under Notifications.

"Are you looking for this answer? We can Help click Order Now"