Class Notes of Spring 2006

We tried to show the skeleton of a search program.

 

 

Program on p.382

#include<iostream.h>   //HEAD OF FILE
main(){
long int password;
    for(int i=1; i<=3; i++){
        cout<<"ENTER YOUR PASSWORD NUMBER:";
        cin>>password;
        if(password==876123) {cout<<"SUCCESS"<<endl; return 1;}
        cout<<"INCORRECT PASSWORD RE-ENTER:"<<endl;
        }//FOR
    cout<<"SORRY NO MORE";
    return 0;
    }//MAIN

 

 

Programming is art.

Most languages are very alike.

Some languages are CASE-SENSITIVE. If you don't follow the rules you get STNTAX ERROR. They are easy to Fix.

The first line looks like gibberish for beginner. (you don't have to really find out what it means).

C++ is a fast language. It only includes things you need.

As the version of the language becomes newer, it becomes more complicated. Do not you '.h' on the new version.

Header line tells the program to access some external file/s to be included in the program. Java does the same thing.

( ) { to beginners look like gibberish.

{ = to begin.

} = to end.

Main means MAIN FUNCTION, so that means there are sub-programs or sub-fuctions.

Main will be the driver. Like a homepage.

int = Integer (whole number)

long integer (very long whole number)

hint. the first part of programming is to type it.

Like your shopping list.

The next thing is your trying to tell compiler to understand you.

Rule of Language: c++ will obey the rule of c++ language.

Every program is made of 2 types of words. "Your" words and "language" (key/reserved) words.

10 reserved words is enough to know.

Please give me a location that will allow me to store a big whole number.

 

cout<<"ENTER YOUR PASSWORD NUMBER:";

This displays a message (literal).

cin = "let me have it"

Stored in "your" memory.

 

   if(password==876123) {cout<<"SUCCESS "<<endl; return 1;}

This is the heart of the search

 

To change the password, just change the numbers in the if statement if(password==12345)

 

how many times you have a change to try this program???????????????????????????????????

3 times