# Project 0: Learning a little Scilab

#### Due at the end of the first class meeting

On your first day, you should learn enough to get started:

• how to use the computers in the Gosnell lab
• how to start Scilab
• how to write a few very simple programs

#### The "Hello, world" program in Scilab

Run Scilab, and use the editor to create a source code file which looks exactly like this:

```//
//  Print a fixed message to the screen.
//
function hello

mprintf('Hello, world \n');

endfunction

```

Save this file as hello.sci, and then, in the Scilab command interpreter, type

```      getf hello.sci
```
to load the program into memory, and then
```      hello
```
to execute it. Does it work?

Now, edit your program so that it is a bit more complex:

```//
//  Print a message and quit.
//
function hello

for iter = 1 : 10
mprintf('Hello, world  %d \n', iter);
end

endfunction

```

Again, save this as hello.sci, load it via getf, and then execute it. What happens this time?

#### The mini-challenge, Part I

While you are here today in class, try to modify your program so that it counts to 10, but prints out a series of messages like this:

```        Hello, world   1  is odd
Hello, world   2  is even
Hello, world   3  is odd
Hello, world   4  is even
```

and so forth up to 10. Can you figure out how to do it? You might look at the Introduction to Scilab page for some hints on the syntax of if-then . There are several ways to determine if an integer is even or odd; you might use the help facility in Scilab to examine its builtin functions,

#### The mini-challenge, Part II

For those who finish early, try something a bit more challenging. Write a program which prints out something that looks like this -- including the number of digits after the decimal -- all the way up to the square root of 10.

```       The square root of  1 is 1.000
The square root of  2 is 1.414
The square root of  3 is 1.732
The square root of  4 is 2.000
```

When you are done, submit your MATLAB source code to me using the Dropbox facility on the myCourses WWW page.