Learn How to Program Computers


This guide is designed for people with no education in anything at all. No 
programming knowledge, no maths skills, no accounting, geography, history, 
nothing.

After following these steps you will have an understanding of how computers 
actually work, which is more than many university graduates (in 
non-scientific subjects) have. Note that this document would ideally be 
used by a teacher, who presents just a bit at a time to the student, and 
then watches the student experiment with the new knowledge/concepts.

This document was written by Paul Edwards and is released to the public 
domain.

To convert this document into a language you understand, you can use 
http://translate.google.com/


*** STOP ***
*** SLOW DOWN ***

Please understand that the purpose of a tutorial is to LEARN and 
UNDERSTAND. It is not an attempt to see how fast you can type in the below 
commands. Read every line carefully. Spend 10 minutes reading every line if 
required. Read the entire tutorial 20 times (or 200 times) if required. 
It's not that big. And make sure if you don't understand something, you ASK 
someone.

*** STAY SLOW ***
*** REALLY SLOW ***
*** THIS IS NOT A SPEED READING COMPETITION ***
*** NO-ONE CARES HOW FAST YOU COMPLETE THIS ***
*** NO-ONE AT ALL*
*** NO-ONE WILL BE IMPRESSED ***
*** NO-ONE ***



BEFORE we can begin, if you are using a PC, the following is required:

Someone with some basic computer skills needs to set your computer up.

You need to have basic computer skills yourself so that you know how to use 
the mouse etc.

Acquiring the skills required for the above tasks is beyond the scope of 
this document.

Here is what is required for your computer to be set up:

Create a folder somewhere on your PC, e.g. c:\learnp

Download bwbasic from here:

http://pdos.org (the full PDOS/386 distribution has it in the c:\dos 
directory)

and save it into that folder. That completes the setup.


If you are instead using PdAndro on an Android phone, no setup is required.

If you are using the full PDOS/386 distribution, bwbasic is already 
installed and you just need to do "md learnp" to create the directory.



NOW WE CAN START.

If you are using Windows, open a command prompt window. On some computers 
you can do this by going start, programs, accessories, command prompt. On 
other computers you can hold down the "Windows" key and press the letter 
"r" and then type in "cmd". The person who set up your computer should tell 
you how to do this.

Go to the directory (folder) that was previously created, e.g. by using the 
following command sequence on Windows:

c:
cd \learnp

Your screen should look something like this:

C:\Users\Paul>c:

C:\Users\Paul>cd \learnp

C:\learnp>

Type in the following command:

dir

And see if you can see if you can see a file called bwbasic.exe. You should 
see something like this:

C:\learnp>dir
Volume in drive C is OS
Volume Serial Number is DE22-8195

Directory of C:\learnp

2015-05-31 15:12 <DIR> .
2015-05-31 15:12 <DIR> ..
2015-05-12 21:41 278,528 bwbasic.exe
1 File(s) 278,528 bytes
2 Dir(s) 53,421,408,256 bytes free

C:\learnp>

If you do not see such a file, then your computer has not been set up 
properly and you cannot continue.

If using PDOS/386, just do "cd learnp".

If using PdAndro, there is no need to do anything.



Now (on all environments) type in the following:

bwbasic

It should display something like the following:

C:\learnp>bwbasic
########  ##    ## ##      ##    ###    ######## ######## ########
##     ##  ##  ##  ##  ##  ##   ## ##      ##    ##       ##     ##
##     ##   ####   ##  ##  ##  ##   ##     ##    ##       ##     ##
########     ##    ##  ##  ## ##     ##    ##    ######   ########
##     ##    ##    ##  ##  ## #########    ##    ##       ##   ##
##     ##    ##    ##  ##  ## ##     ##    ##    ##       ##    ##
########     ##     ###  ###  ##     ##    ##    ######## ##     ##


                                    ########     ###     ######  ####  
######
                                    ##     ##   ## ##   ##    ##  ##  ##    
##
                                    ##     ##  ##   ##  ##        ##  ##
                                    ########  ##     ##  ######   ##  ##
                                    ##     ## #########       ##  ##  ##
                                    ##     ## ##     ## ##    ##  ##  ##    
##
                                    ########  ##     ##  ######  ####  
######

Bywater BASIC Interpreter, version 3.00
Copyright (c) 1993, Ted A. Campbell
Copyright (c) 1995-1997, Jon B. Volkoff
Copyright (c) 2014-2015, Howard Wulf, AF5NE

bwBASIC:


type in the following (starting with the word "print"):

bwBASIC: print "hello"

When you hit enter, it should respond like this:

bwBASIC: print "hello"
hello

See how it printed the word "hello" on the screen? This is how computers 
work. All computer programming is about giving some commands/instructions 
to the computer and then the computer goes and does it. The command we are 
using here is "print". The word has a meaning in the English language, 
which is to use a machine to write something in ink on a piece of paper. 
That is the printing process. When we use the computer we do something 
similar to the printing process. But instead of printing on paper, we want 
the word to appear on the computer screen. You can see that we have been 
successful in achieving that.

Look carefully at the command:

print "hello"

See how it has double-quotes (") around the word? That is just the way the 
command works. It doesn't really matter why it was designed that way. You 
just have to know the rules. And this is the rule - always put what you 
want printed, inside two double-quotes. If you forget to put double-quotes, 
look what happens:

bwBASIC: print hello
0

Try that out yourself. Leave out the quotes and you can see that it doesn't 
display the word "hello" at all! It instead displays something quite 
different - the number 0! Definitely not what we wanted! It doesn't really 
matter why the computer works this way. You just have to remember the rule 
- always use double-quotes. Computers require the rule to be followed 
EXACTLY all the time. Any small mistake and the computer will get confused, 
and print something very strange. Even stranger than the number 0. Let's 
look at another example:

bwBASIC: print :hello
ILLEGAL COMMAND AFTER LINE NUMBER: 1 hello
bwBASIC:


You can see that if you remember to put double-quotes, it prints what you 
were expecting, ie the word "hello". But if you leave out the 
double-quotes, you instead get something very strange indeed. That is 
called an "error message". Every time you make a mistake when doing 
computer programming, either something strange happens (like the number "0" 
being printed), or you get an error message. Look closely at the error 
message:

ILLEGAL COMMAND AFTER LINE NUMBER: 1 hello

It is saying that the first line that you typed - and you only typed one 
line - line number 1 - has a problem. Note that the computer won't always 
get the line number with the problem correct. For the same reason it 
doesn't print a better error message like "you accidentally typed a colon 
character, and you forgot to put the double quotes too" - it doesn't know! 
Computers are essentially very very dumb machines. They have no idea what 
you are trying to do, and they don't even know what they themselves are 
doing. So don't expect too much.

That is why we have programmers. They know how to look at a line like:

print hello there

and see immediately "oh, you forgot the double-quotes". But a computer will 
just give up. They normally cannot guess what you have done wrong. They 
just generate a strange error message, or do something strange. Actually, 
they don't always give up. Sometimes they will go into a loop, repeating 
the same thing again and again, and you need to reboot (or switch off) your 
computer to stop the program. Do not be concerned about why this happens. 
All you need to remember is that computers are very simple and cannot help 
you if you do something wrong. You will need to find the mistake yourself, 
and you need to follow the rules exactly, otherwise you cannot continue.

Let's try some other things with the "print" command.

Try this:
bwBASIC: print 4+7
11

You can see that the computer knows how to add up already if you ask it to 
do so.


Try this:

bwBASIC: print "one","two","three"
one     two     three

This time, instead of giving the "print" command just one thing to print, 
we gave it a list of 3 things to print. It is possible to give the "print" 
command a list, by using the comma (,) to separate things in the list. But 
note how the computer printed the list. It put a lot of space between the 
things in the list. So that's just another rule to learn - when you print a 
list of things, there is a lot of space between them, which is probably not 
very useful.

Now try this:

bwBASIC: print "one"+"two" + "three"
onetwothree

Here we use the "+" between items to print. And you can see that what "+" 
does is join the items together, and you can see that this time there is no 
space at all between the items, instead of lots of space. Even if you put a 
space on the left and the right of the "+" sign it doesn't make any 
difference - no space is printed.

So what do we do if we want a space?

It is now that you really begin programming. It is questions like this that 
programmers face all the time, and need to come up with a solution 
themselves. See these possible solutions:

bwBASIC: print "one "+"two"
one two
bwBASIC: print "one"+" two"
one two
bwBASIC: print "one" + " " + "two"
one two

Of course you could simply have typed in:
bwBASIC: print "one two"
Later on (when "variables" are introduced), you will see why we didn't use 
that simple solution.


And that's enough of the print command, although you should probably try 
the command some more times to make sure you understand it well. You now 
need to type "quit", which just means that you have finished executing 
commands:

bwBASIC: quit


C:\learnp>

This puts you back to the command prompt. If You are using Windows you can 
now type "exit" to end the command prompt.

C:\learnp>exit


Now let's put the knowledge we have gained so far, and create a real 
program. A program is simply many commands put together in a single place, 
instead of executing them one at a time.

So if you are using Windows, then start notepad, by (on older computers) 
going start, programs, accessories, notepad. On modern computers try doing 
Windows + R and typing "notepad".

If you are using PDOS/386 or PdAndro, then use microemacs by typing "e 
myprog.txt". Or a better filename would use the ".bas" extension to show 
that it is a BASIC file, so, "e myprog.bas". Either will work.


Now type in the following:

print "hello"
print "to everyone"
print "one","two"
end

If using Windows and notepad, save your file as c:\learnp\myprog.txt
If using PDOS/386 or PdAndro then you can save your file with ctrl-x, 
ctrl-s, exit with ctrl-x, ctrl-c. If you make a mistake (like forgetting to 
press ctrl-x), you will need to press ctrl-g to cancel the command.

If using Windows, open the command prompt again, go to c:\learnp again 
(remember from before, the commands are "c:" and "cd \learnp"), and confirm 
that you can see the file, by typing the "dir" command again:

C:\learnp>dir
Volume in drive C is OS
Volume Serial Number is DE22-8195

Directory of C:\learnp

2015-05-31 15:19 <DIR> .
2015-05-31 15:19 <DIR> ..
2015-05-12 21:41 278,528 bwbasic.exe
2015-05-31 15:19 60 myprog.txt
2 File(s) 278,588 bytes
2 Dir(s) 53,420,306,432 bytes free

C:\learnp>

You can verify the contents of the file by going:

C:\learnp>type myprog.txt
print "hello"
print "to everyone"
print "one","two"
end

C:\learnp>


(replace myprog.txt with myprog.bas in all commands if you choose to use 
that extension)


Now type in:

C:\learnp>bwbasic myprog.txt

And hopefully you see:

hello
to everyone
one            two

C:\learnp>


If you typed the program in without mistake, you should be able to see the 
above. This is exactly what we expected, given the commands that we put 
into the program. These are basically the same sort of commands we were 
typing in before, and we saw the result of them before. When you put it 
into a program, you should expect the exact same thing to happen. And we do 
see that! You can ignore the Copyright/header messages. They always come 
up.

If you made a mistake, like this:

C:\learnp>type myprog.txt
print "hello"
prin "to everyone"
print "one","two"
end

(you can see that on the second line, we have mistyped "prin" instead of 
"print").

Then when you go to run the program, you get an error message:

C:\learnp>bwbasic myprog.txt
ILLEGAL COMMAND AFTER LINE NUMBER: 2 prin "to everyone"

(you can see the error message above - the computer gets very confused 
about that second line. It is not smart enough to see that you left out the 
letter "t" even though it is so clear to a human)

You should practice making a mistake like the above, so that you are 
familiar with how to recover from that situation.

Ok, now open your program in notepad (or microemacs) and change it so that 
it looks like this:

C:\learnp>type myprog.txt
print "start"
print "please type your name"
input x$
print x$
print x$
print x$
end

Here we have introduced a new command, called "input". "input" means that 
you want the user (you, in this case), to type in something, e.g. the 
answer to a question. You can see that we're going to print out the message 
"please type your name". This lets the user know what the program is 
expecting them to type (ie, their name). Let's look at that command more 
closely.

input x$

So there is the command, ie "input", and something else, called "x$". This 
may look quite strange. The "x$" is called a VARIABLE, and this is very 
very important in programming. You see, it is necessary for the computer to 
be able to work for EVERYONE, regardless of what their name is. But the 
only way we can know what someone's name is, is by asking them. Then we 
need to store that answer somewhere. The place where we store it is called 
a variable. We may need to store lots of different information. E.g. not 
just someone's name, but also their telephone number. So we create two 
variables, one for the name, and one for the phone number. It is not 
important what these names are. The names could be first_name$ and 
phone_number$. Or x$ and y$. In the example I used x$, but it is more usual 
to make the name more meaningful, so that you can remember what it is used 
for. Most programs have lots and lots of variables, so it is necessary to 
give them good, descriptive names. But this program is simple, so x$ is 
good enough. The variable name ends with a "$" sign to let the computer 
know that we are expecting an answer made of characters, e.g. "John", 
instead of an answer that is just a number, like 78. If the answer is a 
number, like "how many children do you have?", then you would not put a 
"$". You would just put x. Or num_children. But there's no need to worry 
about that for now. For now it is enough to know that we need to put a "$" 
as the last character of the variable name.

So what we're expecting to happen when the line:

input x$

is executed, is for the computer to allow you to type an answer, e.g. maybe 
your name is John, and for those 4 letters to be stored together in the 
variable called x$ so that we can later do something with x$. A very simple 
thing we might do with x$ is to simply print it out. And that is exactly 
what we do on the next line!

print x$

Notice how we didn't use double quotes. Ie we didn't say print "x$". 
Previously we said that you should always use double-quotes, otherwise it 
won't work. You'll get an error or a strange result. But this is an 
exception. If you put just a variable name by itself, the computer (ie the 
print command) knows that you want to print the CONTENTS of that variable. 
Ie the name you stored previously. E.g. the 4-letter word "John" might have 
been stored previously. So this command is just telling the computer that 
we want "John" printed on the screen.

We have this exact same command 2 more times, ie the next lines are:

print x$
print x$

That's a total of 3 lines all with the exact same thing on it. So what does 
that mean? Simple! We want to print the user's name 3 times. Let's run the 
program now, so that we can see it in action!

C:\learnp>bwbasic myprog.txt
start
please type your name
?

See what has happened. We had a print command for "start", so we see 
"start" printed on the screen. We had a print command asking the user to 
type in their name, and we can see that on the screen too. What you weren't 
expecting was to see a "?". That is just a feature of the computer 
(programming language). Whenever the computer sees "input" it automatically 
realizes that it needs some information from the user of the computer. 
Rather than just be quiet and wait for the user to start typing something, 
it is instead noisy, and says "I have a question for you - I am waiting for 
you now". Other programming languages (there's a huge list available here: 
http://www.99-bottles-of-beer.net/) do not print that "?", but this one 
does. In the same way that humans have many different languages in the 
world, like English, Chinese, Spanish, French - computers have many 
different languages too. So this language (called "Basic") sees the word 
"input" and automatically prints "?" to try to encourage the user to start 
typing something. It has no idea what the user is going to type, and it has 
no idea what the programmer is expecting the user to type. The only thing 
it knows is that the answer needs to go into x$.

So now it is time for the user (you) to answer the question that the 
computer is trying to ask (because of your program). Let's say your name is 
"Elizabeth", not "John". Let's see what happens:

C:\learnp>bwbasic myprog.txt
start
please type your name
? Elizabeth
Elizabeth
Elizabeth
Elizabeth

C:\learnp>

As you can see, the name "Elizabeth" is printed out 3 times (after you type 
it in once). This is exactly what we were expecting. Try it with your own 
name and it should all work fine.

Let's now add another line to your program. Just before the "end" type in:

print "i think " + x$ + " is a great name"

You have previously seen how we joined together items in a list, such as 
"one" and "two", to make "onetwo". This time we are doing something a bit 
different. One of the items in the list is the variable name we used before 
- x$. So just as before, since the variable name does not have 
double-quotes around it, it means that we want the CONTENTS of that 
variable used. And how do we want the variable used? We want it combined 
with the words "i think" on the left, and the words "is a great name" on 
the right. So what are we expecting as a result? Well, it obviously depends 
on what the person's name is. But let's say once again that the person's 
name is "John". We're expecting it to say "i think John is a great name".

Let's try it.

C:\learnp>type myprog.txt
print "start"
print "please type your name
input x$
print x$
print x$
print x$
print "i think " + x$ + " is a great name"
end

C:\learnp>bwbasic myprog.txt
start
please type your name
? Mary
Mary
Mary
Mary
i think Mary is a great name

C:\learnp>

If you didn't get that result (for your name) then it means you have made a 
mistake in typing in the new line. You need to look very carefully to see 
what you have typed wrong. The computer can't tell you what you've done 
wrong. Only your skill as a programmer can find out what is wrong. Mistakes 
in computer programs are called "bugs". Trying to find bugs is called 
"debugging".


Now let's introduce a new concept - repetition. You can see that when we 
wanted the name repeated 3 times, we just typed the command in. But what if 
we wanted that repeated 10 times instead of 3? Or 10,000 times? It is not 
practical to type the repeated thing in multiple times. Fortunately there 
is a way of telling the computer you want something repeated. One way is as 
follows:

C:\learnp>type myprog.txt
print "start"
print "please type your name"
input x$
for y = 1 to 5
print x$
next y
print "i think " + x$ + " is a great name"
end

C:\learnp>bwbasic myprog.txt
start
please type your name
? john
john
john
john
john
john
i think john is a great name

C:\learnp>


Can you see how that was done? Here's the relevant code:

for y = 1 to 5
print x$
next y

It is called a "for loop". In the for loop you use a variable (in this case 
"y") which starts off having the value "1" and each time around the loop it 
gets incremented by 1. Let's make that clearer.

C:\learnp>type myprog.txt
print "start"
print "please type your name"
input x$
for y = 1 to 5
print y, x$
next y
print "i think " + x$ + " is a great name"
end

C:\learnp>bwbasic myprog.txt
start
please type your name
? john
1 john
2 john
3 john
4 john
5 john
i think john is a great name

C:\learnp>


You can see the counter ("y") being printed out each time through the loop. 
That's because of this line within the loop:

print y, x$

You can see that we're not just printing the name (x$). We're also printing 
the loop counter ("y").

Now that we've covered the "for" command, let's introduce another construct 
- "IF". In English we may say IF your name is John you must be a man. Let's 
put that exact concept to work:

C:\learnp>type myprog.txt
print "start"
print "please type your name"
input x$
if x$ = "john" then
print "i think you are a man"
elseif x$ = "mary" then
print "i think you are a woman"
else
print "I'm not sure whether you are male or female"
end if
end

C:\learnp>bwbasic myprog.txt
start
please type your name
? mary
i think you are a woman

C:\learnp>bwbasic myprog.txt
start
please type your name
? john
i think you are a man

C:\learnp>bwbasic myprog.txt
start
please type your name
? fred
I'm not sure whether you are male or female

C:\learnp>


So you can see from this code:

if x$ = "john" then
print "i think you are a man"

how we are checking the name entered by the user and if it is John, we 
conclude that it is a man's name. This technique can be repeated to cover 
many more male names that the program can recognize.

We have also introduced the concept of "ELSEIF". If the first "IF" is not 
satisfied then the computer executes the "ELSEIF" statement, and this 
structure can be repeated until you have covered all the names you wish to 
have special coding for.

Let's now use the "WHILE" construct.

C:\learnp>type myprog.txt
print "start"
while x$ <> "quit"
print "please type your name"
input x$
if x$ = "john" then
print "i think you are a man"
elseif x$ = "mary" then
print "i think you are a woman"
else
print "I'm not sure whether you are male or female"
end if
wend
end

C:\learnp>bwbasic myprog.txt
start
please type your name
? paul
I'm not sure whether you are male or female
please type your name
? john
i think you are a man
please type your name
? mary
i think you are a woman
please type your name
? quit
I'm not sure whether you are male or female

C:\learnp>


See this line:

while x$ <> "quit"

That says that while the x$ (name) variable is not equal (<>) to the word 
"quit", execute everything until you hit the "wend". This loop will repeat 
infinitely until the user types the word "quit".


This concludes the basic concepts in the BASIC language. You have now moved 
from white belt to yellow belt:
https://en.wikipedia.org/wiki/Rank_in_Judo#Australia

People don't write serious software in BASIC, they instead use another 
language, like "C".

Here is that last program converted to C:

C:\learnp>type myprog.c
#include <stdio.h>
#include <string.h>

int main(void)
{
    char name[100] = "";

    printf("start\n");
    while (strcmp(name, "quit") != 0)
    {
        printf("please type your name\n");
        scanf("%s", name);
        if (strcmp(name, "john") == 0)
        {
            printf("i think you are a man\n");
        }
        else if (strcmp(name, "mary") == 0)
        {
            printf("i think you are a woman\n");
        }
        else
        {
            printf("I'm not sure whether you are male or female\n");
        }
    }
    return (0);
}

C:\learnp>


So save the above program as "myprog.c" in the "learnp" directory.

Then get gccwin etc from c:\dos in PDOS/386 from http://pdos.org
Or if you're using PDOS/386, it is already available.
If using PdAndro, they are already available too, but the commands are 
different.

Then compile the program. Normally with a compiler that is a single, simple 
command. Like this with Borland C++:

C:\learnp>bcc32 myprog.c
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
myprog.c:
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland

And after compilation you get:

C:\learnp>dir myprog.exe
Volume in drive C has no label.
Volume Serial Number is 4ABA-BE3B

Directory of C:\learnp

2013-06-16 12:29 66,048 myprog.exe
1 File(s) 66,048 bytes
0 Dir(s) 687,535,136,768 bytes free


But gccwin (for Windows or PDOS/386), and gccarm (for PdAndro), are more 
complicated and expose the low-level details.

For Windows and PDOS/386, use these commands:

C:\learnp>gccwin -S -I \devel\pdos\pdpclib -o myprog.s myprog.c

This converts C to assembler and produces a myprog.s assembler file. You 
don't need to look at this because it is assembler, but you are programming 
in C, so this isn't your problem.

C:\learnp>pdas --oformat coff -o myprog.obj myprog.s

This converts assembler to object (machine) code.

D:\learnp>pdld -o myprog.exe \devel\pdos\pdpclib\w32start.obj myprog.obj 
\devel\pdos\pdpclib\msvcrt.lib

This links the object code together with other required support code into 
an executable (also machine code).


For PdAndoro, use these commands (assuming you are in learnp - which can be 
created by first running pcomm and then running md learnp and then typing 
"exit" - because bios.exe doesn't have a "md" command at the moment):

gccarm -S -O0 -mapcs-32 -fno-builtin -D__PDOS386__ -D__PDOSGEN__ 
-D__ARMGEN__ -I ../pdpclib -I ../generic -o myprog.s myprog.c

(convert from C to ARM assembler)

asarm -o myprog.o myprog.s

(convert from ARM assembler to ARM object code)

ldarm -N -o myprog.exe ../pdpclib/pgastart.o world.o ../pdpclib/armsupa.o

(link program together with support code)

Some things to note:

These commands are very long, so it is best if you put them into a .bat 
file, e.g. "e temp.bat", and execute that, e.g. "temp", in the absence of 
command recall and editing.

And don't worry about the fact that you have to run these long commands in 
the first place - this is normally put into a makefile, so you just run 
pdmake to execute it (or in the case of PdAndro, you use the --redirect 
option and then execute a batch file).


Now to run it, we just type the name:

C:\learnp>myprog
start
please type your name
paul
I'm not sure whether you are male or female
please type your name
mary
i think you are a woman
please type your name
john
i think you are a man
please type your name
quit
I'm not sure whether you are male or female


You can match up virtually every line in the C program to the BASIC 
version.

Note that unlike BASIC, you need to define all the variables you use. So 
here is the "name" variable being defined as 100 characters in size:

char name[100] = "";


Once you understand the above C program, you have moved from yellow belt to 
orange belt.


At this point it is better that you (effectively) switch operating systems, 
not just language. Instead of programming in BASIC on Windows, we will 
instead start programming in C on MVS. Even if you end up getting a job as 
a Unix C programmer, this will ensure that you don't pick up any bad habits 
like using open() instead of fopen() to open a file.

Someone needs to set up your computer first so that you can run MVS/380. 
You can learn about that operating system at http://mvs380.sourceforge.net

Once you have MVS/380 installed properly you should be able to use the 
"runmvs" command. This uses batch processing instead of interactive, ie you 
need to put all the answers to the questions in advance. Also the method of 
compilation is more complicated than just running bcc32 and running the 
program by name. We instead use a scripting language called "JCL" which is 
quite primitive. Here is the required JCL to compile and execute the above 
program:

//MVSGCCR  JOB CLASS=C,REGION=0K
//*
//* Compile a C program then run it
//*
//CCOMP    PROC GCCPREF='GCC',PDPPREF='PDPCLIB',
// COS1='-Os -S',
// COS2='-o dd:out -',
// P=''
//*
//CREATE   EXEC PGM=IEFBR14
//DD1      DD DSN=&&LOADLIB,DISP=(,PASS),
// DCB=(RECFM=U,LRECL=0,BLKSIZE=6144),
// SPACE=(6144,(100,100,44)),UNIT=SYSALLDA
//*
//COMP     EXEC PGM=GCC,
// PARM='&COS1 &COS2'
//STEPLIB  DD DSN=&GCCPREF..LINKLIB,DISP=SHR
//INCLUDE  DD DSN=&PDPPREF..INCLUDE,DISP=SHR
//SYSINCL  DD DSN=&PDPPREF..INCLUDE,DISP=SHR
//OUT      DD DSN=&&TEMP1,DISP=(,PASS),UNIT=SYSALLDA,
//            DCB=(LRECL=80,BLKSIZE=6160,RECFM=FB),
//            SPACE=(6160,(500,500))
//SYSIN    DD DUMMY
//SYSPRINT DD SYSOUT=*
//SYSTERM  DD SYSOUT=*
//*
//ASM      EXEC PGM=ASMA90,
//            PARM='DECK,NOLIST',
//            COND=(4,LT,COMP)
//SYSLIB   DD DSN=SYS1.MACLIB,DISP=SHR,DCB=BLKSIZE=32720
//         DD DSN=&PDPPREF..MACLIB,DISP=SHR
//SYSUT1   DD UNIT=SYSALLDA,SPACE=(CYL,(20,10))
//SYSUT2   DD UNIT=SYSALLDA,SPACE=(CYL,(20,10))
//SYSUT3   DD UNIT=SYSALLDA,SPACE=(CYL,(2,1))
//SYSPRINT DD SYSOUT=*
//SYSLIN   DD DUMMY
//SYSGO    DD DUMMY
//SYSPUNCH DD DSN=&&OBJSET,UNIT=SYSALLDA,SPACE=(80,(240,200)),
//            DISP=(,PASS)
//SYSIN    DD DSN=&&TEMP1,DISP=(OLD,DELETE)
//*
//LKED     EXEC PGM=IEWL,PARM='MAP,LIST'
//SYSLIN   DD DSN=&&OBJSET,DISP=(OLD,DELETE)
//SYSLIB   DD DSN=&PDPPREF..NCALIB,DISP=SHR
//SYSLMOD  DD DSN=&&LOADLIB(CPROG),DISP=(OLD,PASS)
//SYSUT1   DD UNIT=SYSALLDA,SPACE=(CYL,(2,1))
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//*
//EXECC    EXEC PGM=CPROG,
//         PARM='&P',
//         COND=(0,LT,LKED)
//STEPLIB  DD  DSN=&&LOADLIB,DISP=(OLD,PASS)
//SYSPRINT DD  SYSOUT=*
//SYSTERM  DD  SYSOUT=*
//SYSUDUMP DD  SYSOUT=*
//SYSIN    DD  DUMMY
//*
//         PEND
//*
//S1       EXEC CCOMP,P=''
//COMP.SYSIN DD DATA,DLM='$$'
#include <stdio.h>
#include <string.h>

int main(void)
{
    char name[100] = "";

    printf("start\n");
    while (strcmp(name, "quit") != 0)
    {
        printf("please type your name\n");
        scanf("%s", name);
        if (strcmp(name, "john") == 0)
        {
            printf("i think you are a man\n");
        }
        else if (strcmp(name, "mary") == 0)
        {
            printf("i think you are a woman\n");
        }
        else
        {
            printf("I'm not sure whether you are male or female\n");
        }
    }
    return (0);
}
$$
//*
//EXECC.SYSIN DD *
paul
mary
john
quit
/*
//*
//

Save this as myprog.jcl and then use this command:

C:\learnp>runmvs myprog.jcl output.txt

Now open output.txt using notepad and you should see the results of running 
your program near the end.

After you have found the expected output, thus you now know how to program 
on MVS, you move from orange belt to green belt.

At this point you need to hone your skills in C, and to some extent JCL. 
You will hone your C skills by doing some other tutorials from the 
internet. If you have any problems following the tutorials, you can ask 
your questions (ie questions about programming in C on MVS) here:


https://groups.io/g/hercules-380/messages

Note that if a tutorial asks you to open a file called "input.txt" you will 
instead need to code that as something like "dd:input", and in the JCL you 
need to create an INPUT DD statement modelled off the SYSIN DD statement.

You should now do any C tutorial that you can find on the internet. Here 
are some examples:

https://en.wikibooks.org/wiki/C_Programming

https://www.learn-c.org/

http://fresh2refresh.com/c-tutorial-for-beginners/

https://web.archive.org/web/20170218194459/http://www.iu.hio.no/~mark/CTutorial/CTutorial.html

https://web.archive.org/web/20160316102327/http://www.physics.drexel.edu/students/courses/Comp_Phys/General/C_basics/

None of the above sites are affiliated with me.

If you are intested in learning more about the JCL scripting language, you 
can try reading this IBM manual:

http://www.bitsavers.org/pdf/ibm/370/OS_VS2/Release_3.8_1978/GC28-0692-5_OS_VS2_MVS_JCL_Rel_3.8_Apr84.pdf

Note that IBM is not affiliated with me either.

The above C tutorials are not the definitive definition of the C language. 
The most definitive (ie as close to the C90 standard aka ISO/IEC 9899:1990 
aka ANSI X3.159-1989) version available online is this:

https://web.archive.org/web/20240131002213/https://nvlpubs.nist.gov/nistpubs/Legacy/FIPS/fipspub160.pdf
or a text version:
https://web.archive.org/web/20160304075258/http://flash-gordon.me.uk/ansi.c.txt

Note that neither the ANSI nor ISO C committees are affiliated with me 
either.

After you have gone through the above, or some similar tutorials and are 
confident in the C language, you move from green belt to blue belt.

After you are familiar with the MVS operating system you move from blue 
belt to brown belt.

Black belt is achieved if you ever manage to fix a bug in any flavor of 
PDOS or PDPCLIB.
