Skip to content

ryanulep/cs010_lab02

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

CS 10 - Lab 2: Hello, You!

Overview

You will be writing a simple program involving both input and output. The program initially prompts the user for his or her name. After the prompt the program should acquire a name through input. Once the name is acquired, the program asks the user a question about nice days. After which, the user will enter how many nice days he or she wants. Lastly, the program outputs a response back to the user; the response will use all the provided inputs, and double the number of nice days!

Setup

  1. Create a file named lab2.cpp within the proper directory for Lab 2.
  2. Fill the file with the contents of your lab1.cpp file.
  3. Delete everything between main's left and right curly braces, {and }, except the return0;
  4. Make sure the assessment header in your new file is properly filled in.

Think About the Problem

  1. What we call a program is basically an algorithm to solve a given problem. With small programs (solving simple problems), we can often bypass the step of separately designing a general algorithm, and simply use comments within our source code to lay out our problem & its solution before we write any code.
  2. Based on the description of the problem, what are the tasks the program must do?
    • each task should be a comment
    • recall comments start with //
    • each comment should be an English description of the task, not C++ code
  3. Certain tasks may require storage of values, we store values in variables.
    • Take a moment to identify how many items you wish to store, based on your tasks.
    • Create a comment with an English description for each item you wish to store.
    • Now, think about the type of variable which is required to store each of the identified items.
    • Depending on the program, you may use different datatypes for different variables.
  4. Now, within your comments is a clearly outlined program. No C++ code should exist within your source file; except the basic starting structure of the main function, think of it as a C++ code template.

Program Your Solution

  1. Now, on the line following each of your comments, write the C++ code that performs that task: this allows a reader to read and think about the comment, and then check (or skip) the actual implementation.
  2. You will often need to to check an example program run to get your output to be as expected. We will generally provide some example runs in the specification (e.g. below), but we also provide executables for some assignments in the cs010_programs area.

Known Bugs

No currently known bugs!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages