COMPUTER LANGUAGE

5. COMPUTER LANGUAGE

All languages like English have their very own alphabet and grammar. We use this alphabet to make words having meaning, and in turn, make sentences. We can’t permute these words in any way we like to make a meaningful sentence. We need to use grammar and logic to form sentences that others would understand.

Zaman eating loves apple.

This is a sentence with no meaning. Each of these words are meaningful though. The correct sentence would be

Zaman loves eating apples.

Similarly,

Zaman love eating apples.

is meaningless. Love should have been loves. This is a result of improper grammar usage. Grammar is nothing but a set of rules to be followed to make words and sentences that others will understand.

A computer language is similar. It has a set of words (called tokens) and a grammar. We use computer language to write programs that compilers understand.

6. PATTERNS WITHIN COMPUTER PROGRAMS


What constitutes program logic? The answer lays in the various patterns that we often follow. We shall consider many examples that would help us identify these patterns. We will execute each instruction from top to bottom. That is topmost instruction will be the first one to be executed.

Example 6.1
You will be given a sample of edible items. Write an algorithm (a procedure, a program) to find if an item can be a sweet dish. Remember, you don’t know at start the number of items in the sample.

Start algorithm.

while there is an item on the plate execute statements within brackets
{

pic up an item.
eat it.
if the item was sweet execute next statement
mark it as a sweet dish.

}

End algorithm.

0 Response to "COMPUTER LANGUAGE"

Post a Comment