COSC 1320 Lecture Notes - Lecture 1: Pseudocode

29 views2 pages
of 2
Lecture 1;//Intro to programming
//Write a program to read 2 numbers. Compare them and print the smallest
//1 - 2 input variables and I output, type integer
//Initialize and read from the keyboard the 2 inputs...output variable is 0
//Compare if 1st < 2nd - 1st is smallest otherwise the second is smallest
//Print...The smallest number is 1st and the second is....
#include <iostream>
using namespace std;
//this program is to compare 2 numbers and print the smallest
int main(){
int nb1;
int nb2;//don’t forget the semi colons after each statement
//2 initialize
cout<< "Enter the first Number\n";
cout<< "Enter the second number\n";
//3-process, comparison
if (nb1 < nb2)
cout<< " the smallest is " << nb1 <<endl;
else if(nb1 < nb2)
cout<< " the smallest is " << nb2 <<endl;
cout<< "the numbers are equal";
find more resources at
find more resources at
When asked to program always pseudocode; that is write it down in plain English on paper before
writing in code. Use the 4 steps. Declare, Initialize, Process, Print
find more resources at
find more resources at