A bit of logic to code.
Every program should have at least these two points: start and stop. A program is like a todo list. You could use English, Spanish, or a host of other languages to use your todo list. More on logic steps later.
So with computer languages you can do the same thing. Examples:
in C
#include <stdio.h>
main()
{
}
or
In basic:
rem start
rem stop
In Bash:
#!/bin/bash
# start# stop
Of course that does not really do anything in that sequence. Now let's go to the beginner's hello world example and see how things change. Yes we are adding a step here in the sequence. Let's just use english for now.
Examples:
in C
#include <stdio.h>
main()
{
printf("Hello, world.\n");
}
In Basic
rem start
print "Hello, world."
rem stop
end
Bash
#!/bin/bash
# start
echo Hello, world.
# stop
You can not get any simpler than that for a start, In some ways you are an architect putting rooms together for a house such as a bedroom, bathroom, kitchen, den, living room or etc. With logic you can have loops (repetitive actions), Decision structures (if
this happens then do one or more things, or else just do something else), or just a sequence of steps. More on all of this later.
Comments
Post a Comment