Skip to main content
Ctrl+K

Introduction to Computer Science in C# (09 May 2026)

  • Introduction to Computer Science in C#
  • Context
    • Motivation for This Book
    • Resources Online
    • Downloading and Reading Options
    • Computer Science, Broadly
    • Chapter Review Questions
  • C# Data and Operations
    • A Sample C# Program
    • Lab: Editing, Compiling, and Running with Xamarin Studio
    • Lab: Editing, Compiling, and Running with Visual Studio Code
    • Lab: Editing, Compiling, and Running with Vim
    • Arithmetic
    • Variables and Assignment
    • Reading C# Syntax Templates
    • Strings, Part I
    • Writing to the Console
    • C# Program Structure
    • Combining Input and Output
    • String Special Cases
    • Substitutions in Console.WriteLine
    • Value Types and Conversions
    • Learning to Solve Problems
    • Lab: Division Sentences
    • Chapter Review Questions
  • Defining Functions of your Own
    • A First Function Definition
    • Multiple Function Definitions
    • Function Parameters
    • Multiple Function Parameters
    • Returned Function Values
    • Two Roles: Writer and Consumer of Functions
    • Local Scope
    • Static Variables
    • Not using Return Values
    • Library Classes
    • Tracebacks
    • Static Function Summary
    • Chapter Review Questions
  • Basic String Operations
    • String Indexing
    • Some Instance Methods and the Length Property
    • A Creative Problem Solution
    • Lab: String Operations
    • Chapter Review Questions
  • Decisions
    • Conditions I
    • Simple if Statements
    • if-else Statements
    • More Conditional Expressions
    • Multiple Tests and if-else Statements
    • If-statement Pitfalls
    • Compound Boolean Expressions
    • Nested if Statements
    • Chapter Review Questions
  • While Loops
    • While-Statements
    • While-Statements with Sequences
    • Interactive while Loops
    • Short-Circuiting && and ||
    • While Examples
    • More String Methods
    • User Input: UI
    • Greatest Common Divisor
    • Do-While Loops
    • Number Guessing Game Lab
    • Chapter Review Questions
  • Foreach Loops
    • foreach Syntax
    • foreach Examples
    • Chapter Review Questions
  • For Loops
    • For-Statement Syntax
    • Examples With for Statements
    • Lab: Loops
    • Chapter Review Questions
  • Files, Paths, and Directories
    • Files As Streams
    • Writing Files
    • Reading Files
    • Path Strings
    • Directory Class
    • Command Line Execution
    • FIO Helper Class
    • Chapter Review Questions
  • Arrays
    • One Dimensional Arrays
    • Musical Scales and Arrays
    • Linear Searching
    • Sorting Algorithms
    • Binary Searching
    • Lab: Arrays
    • Lab: Performance
    • Multi-dimensional Arrays
    • Chapter Review Questions
  • Lists
    • List Syntax
    • .Net Library (API)
    • Chapter Review Questions
  • Dictionaries
    • Dictionary Syntax
    • Dictionary Efficiency
    • Dictionary Examples
    • Lab: File Data and Collections
    • Chapter Review Questions
  • Classes and Object-Oriented Programming
    • A First Example of Class Instances: Contact
    • Class Instance Examples
    • The Rational Class
    • Planning A Class Structure
    • Classes And Structs
    • Defining Operators (Optional)
    • Chapter Review Questions
  • Testing
  • Interfaces
    • Rationals Revisited
    • Csproject Revisited
    • Chapter Review Questions
  • Recursion
  • Data Structures
  • Appendix
    • Development Tools
    • Xamarin Studio
    • Command Line Introduction
    • Precedence of Operators
    • Homework: Grade Calculation
    • Homework: Grade Calculation from Individual Scores
    • Homework: Grade File
    • Homework: Book List
    • Group Project
    • Lab: Version Control
    • Mercurial and Teamwork
    • Acknowledgments
  • Repository
  • Open issue

While Loops

While Loops#

  • While-Statements
    • Sum To n
  • While-Statements with Sequences
    • One Character Per Line
    • Print Vowels Function
    • IsDigits Function
    • Play Computer With a Loop
  • Interactive while Loops
    • Agree Function Exercise
    • Interactive Sum Exercise
    • Safe Whole Number Input Exercise
  • Short-Circuiting && and ||
  • While Examples
    • Bisection Method
    • Savings Exercise
    • Strange Sequence Exercise
    • Roundoff Exercise II
  • More String Methods
    • Count Repetitions in a String Exercise
    • Safer PromptInt and PromptDouble Exercise
    • Safest PromptInt Exercise
  • User Input: UI
  • Greatest Common Divisor
    • Euclid’s Algorithm
    • GCD “Brute Force” Method
    • GCD Subtraction Method
    • GCD Remainder Loop
    • Preview: Recursive GCD
  • Do-While Loops
    • Loan Table Exercise
  • Number Guessing Game Lab
    • Part 1: No Hints; Fixed Secret Number
    • Part 2: Add Hints
    • Part 3: Add a Random Secret Number
    • Part 4: Let the Player Set the Range of Values
    • Part 5: Count the Guesses
    • Possible Extra Credit Improvements or Variations
  • Chapter Review Questions

previous

Chapter Review Questions

next

While-Statements

By Andrew N. Harrington and George K. Thiruvathukal

© Copyright 2012-2021, Andrew N. Harrington and George Thiruvathukal.

Last updated on 09-May-2026 16:14:48.