CSC 101 Lecture Notes Week 1
Introduction to the Course
Introduction to Programming and Problem Solving
PROGRAM INSTRUCTIONS: EXPLANATORY COMMENTS:
_______________________________________________________________________________
program Begin the program
let x be an integer variable Declare a variable to hold the input
read x Read the number typed on the screen
if x > 0 then Check if the number is > 0 (i.e., positive)
print "yes" If so, print "yes" on the screen
else If not,
print "no" print "no" on the screen
end End the program
#include <iostream.h> // The C++ input/output library
int main() { // C++ programs always start with this header
int x; // Declare a variable to hold the input number
cin >> x; // Input the number typed on the screen
if (x > 0) // Check if the number is > 0 (i.e., positive)
cout << "yes"; // If so, output "yes" to the screen
else // If not,
cout << "no"; // output "no" to the screen
} // End of main program (matches the "{")