Monday, October 8, 2012

Idioms


A Bird In The Hand Is Worth Two In The Bush:
Having something that is certain is much better than taking a risk for more, because chances are you might lose everything.

A Blessing In Disguise:
Something good that isn't recognized at first.

A Chip On Your Shoulder:
Being upset for something that happened in the past.

A Dime A Dozen:
Anything that is common and easy to get.

A Doubting Thomas:
A skeptic who needs physical or personal evidence in order to believe something.

A Drop in the Bucket:
A very small part of something big or whole.

A Fool And His Money Are Easily Parted:
It's easy for a foolish person to lose his/her money.

A House Divided Against Itself Cannot Stand:
Everyone involved must unify and function together or it will not work out.

A Leopard Can't Change His Spots:
You cannot change who you are.

A Penny Saved Is A Penny Earned:
By not spending money, you are saving money (little by little).

A Picture Paints a Thousand Words:
A visual presentation is far more descriptive than words.

A Piece of Cake:
A task that can be accomplished very easily.

A Slap on the Wrist:
A very mild punishment.

A Taste Of Your Own Medicine:
When you are mistreated the same way you mistreat others.

A Toss-Up:
A result that is still unclear and can go either way.

Actions Speak Louder Than Words:
It's better to actually do something than just talk about it.

Add Fuel To The Fire:
Whenever something is done to make a bad situation even worse than it is.

Against The Clock:
Rushed and short on time.

All Bark And No Bite:
When someone is threatening and/or aggressive but not willing to engage in a fight.

All Greek to me:
Meaningless and incomprehensible like someone who cannot read, speak, or understand any of the Greek language would be.

All In The Same Boat:
When everyone is facing the same challenges.

An Arm And A Leg:
Very expensive. A large amount of money.

An Axe To Grind:
To have a dispute with someone.

Apple of My Eye:
Someone who is cherished above all others.

As High As A Kite:
Anything that is high up in the sky.

At The Drop Of A Hat:
Willing to do something immediately.


B

Back Seat Driver:
People who criticize from the sidelines, much like someone giving unwanted advice from the back seat of a vehicle to the driver.

Back To Square One:
Having to start all over again.

Back To The Drawing Board:
When an attempt fails and it's time to start all over.

Baker's Dozen:
Thirteen.

Barking Up The Wrong Tree:
A mistake made in something you are trying to achieve.

Beat A Dead Horse:
To force an issue that has already ended.

Beating Around The Bush:
Avoiding the main topic. Not speaking directly about the issue.

Bend Over Backwards:
Do whatever it takes to help. Willing to do anything.

Between A Rock And A Hard Place:
Stuck between two very bad options.

Bite Off More Than You Can Chew:
To take on a task that is way to big.

Bite Your Tongue:
To avoid talking.

Blood Is Thicker Than Water:
The family bond is closer than anything else.

Blue Moon:
A rare event or occurance.

Break A Leg:
A superstitious way to say 'good luck' without saying 'good luck', but rather the opposite.

Buy A Lemon:
To purchase a vehicle that constantly gives problems or stops running after you drive it away.



C

Can't Cut The Mustard :
Someone who isn't adequate enough to compete or participate.

Cast Iron Stomach:
Someone who has no problems, complications or ill effects with eating anything or drinking anything.

Charley Horse:
Stiffness in the leg / A leg cramp.

Chew someone out:
Verbally scold someone.

Chip on his Shoulder:
Angry today about something that occured in the past.

Chow Down:
To eat.

Close but no Cigar:
To be very near and almost accomplish a goal, but fall short.

Cock and Bull Story:
An unbelievable tale.

Come Hell Or High Water:
Any difficult situation or obstacle.

Crack Someone Up:
To make someone laugh.

Cross Your Fingers:
To hope that something happens the way you want it to.

Cry Over Spilt Milk:
When you complain about a loss from the past.

Cry Wolf:
Intentionally raise a false alarm.

Cup Of Joe:
A cup of coffee.

Curiosity Killed The Cat:
Being Inquisitive can lead you into a dangerous situation.

Cut to the Chase:
Leave out all the unnecessary details and just get to the point.



D

Dark Horse:
One who was previously unknown and is now prominent.

Dead Ringer:
100% identical. A duplicate.

Devil's Advocate:
Someone who takes a position for the sake of argument without believing in that particular side of the arguement. It can also mean one who presents a counter argument for a position they do believe in, to another debater.

Dog Days of Summer:
The hottest days of the summer season.

Don't count your chickens before they hatch:
Don't rely on it until your sure of it.

Don't Look A Gift Horse In The Mouth:
When someone gives you a gift, don't be ungrateful.

Don't Put All Your Eggs In One Basket:
Do not put all your resources in one possibility.

Doozy:
Something outstanding.

Down To The Wire:
Something that ends at the last minute or last few seconds.

Drastic Times Call For Drastic Measures:
When you are extremely desperate you need to take extremely desperate actions.

Drink like a fish:
To drink very heavily.

Drive someone up the wall:
To irritate and/or annoy very much.

Dropping Like Flies:
A large number of people either falling ill or dying.

Dry Run:
Rehearsal.



E

Eighty Six:
A certain item is no longer available. Or this idiom can also mean, to throw away.

Elvis has left the building:
The show has come to an end. It's all over.

Ethnic Cleansing:
Killing of a certain ethnic or religious group on a massive scale.

Every Cloud Has A Silver Lining:
Be optomistic, even difficult times will lead to better days.

Everything But The Kitchen Sink:
Almost everything and anything has been included.

Excuse my French:
Please forgive me for cussing.

Cock and Bull Story:
An unbelievable tale.

Cock and Bull Story:
An unbelievable tale.



F

Feeding Frenzy:
An aggressive attack on someone by a group.

Field Day:
An enjoyable day or circumstance.

Finding Your Feet:
To become more comfortable in whatever you are doing.

Finger lickin' good:
A very tasty food or meal.

Fixed In Your Ways:
Not willing or wanting to change from your normal way of doing something.

Flash In The Pan:
Something that shows potential or looks promising in the beginning but fails to deliver anything in the end.

Flea Market:
A swap meet. A place where people gather to buy and sell inexpensive goods.

Flesh and Blood:
This idiom can mean living material of which people are made of, or it can refer to someone's family.

Flip The Bird:
To raise your middle finger at someone.

Foam at the Mouth:
To be enraged and show it.

Fools' Gold:
Iron pyrites, a worthless rock that resembles real gold.

French Kiss:
An open mouth kiss where tongues touch.

From Rags To Riches:
To go from being very poor to being very wealthy.

Fuddy-duddy:
An old-fashioned and foolish type of person.

Full Monty:
This idiom can mean either, "the whole thing" or "completely nude".

Funny Farm:
A mental institutional facility.



G

Get Down to Brass Tacks:
To become serious about something.

Get Over It:
To move beyond something that is bothering you.

Get Up On The Wrong Side Of The Bed:
Someone who is having a horrible day.

Get Your Walking Papers:
Get fired from a job.

Give Him The Slip:
To get away from. To escape.

Go Down Like A Lead Balloon:
To be received badly by an audience.

Go For Broke:
To gamble everything you have.

Go Out On A Limb:
Put yourself in a tough position in order to support someone/something.

Go The Extra Mile:
Going above and beyond whatever is required for the task at hand.

Good Samaritan:
Someone who helps others when they are in need, with no discussion for compensation, and no thought of a reward.

Graveyard Shift:
Working hours from about 12:00 am to 8:00 am. The time of the day when most other people are sleeping.

Great Minds Think Alike:
Intelligent people think like each other.

Green Room:
The waiting room, especially for those who are about to go on a tv or radio show.

Gut Feeling:
A personal intuition you get, especially when feel something may not be right.



H

Haste Makes Waste:
Quickly doing things results in a poor ending.

Hat Trick:
When one player scores three goals in the same hockey game. This idiom can also mean three scores in any other sport, such as 3 homeruns, 3 touchdowns, 3 soccer goals, etc.

Have an Axe to Grind:
To have a dispute with someone.

He Lost His Head:
Angry and overcome by emotions.

Head Over Heels:
Very excited and/or joyful, especially when in love.

Hell in a Handbasket:
Deteriorating and headed for complete disaster.

High Five:
Slapping palms above each others heads as celebration gesture.

High on the Hog:
Living in Luxury.

Hit The Books:
To study, especially for a test or exam.

Hit The Hay:
Go to bed or go to sleep.

Hit The Nail on the Head:
Do something exactly right or say something exactly right.

Hit The Sack:
Go to bed or go to sleep.

Hocus Pocus:
In general, a term used in magic or trickery.

Hold Your Horses:
Be patient.



I

Icing On The Cake:
When you already have it good and get something on top of what you already have.

Idle Hands Are The Devil's Tools:
You are more likely to get in trouble if you have nothing to do.

If It's Not One Thing, It's Another:
When one thing goes wrong, then another, and another...

In Like Flynn:
To be easily successful, especially when sexual or romantic.

In The Bag:
To have something secured.

In The Buff:
Nude.

In The Heat Of The Moment:
Overwhelmed by what is happening in the moment.

In Your Face:
An aggressive and bold confrontation.

It Takes Two To Tango:
A two person conflict where both people are at fault.

It's A Small World:
You frequently see the same people in different places.

Its Anyone's Call:
A competition where the outcome is difficult to judge or predict.

Ivy League:
Since 1954 the Ivy League has been the following universities: Columbia, Brown, Cornell, Dartmouth, Yale, Pennsylvania, Princeton, and Harvard.



J

Jaywalk:
Crossing the street (from the middle) without using the crosswalk.

Joshing Me:
Tricking me.



K

Keep An Eye On Him:
You should carefully watch him.

Keep body and soul together:
To earn a sufficient amount of money in order to keep yourself alive .

Keep your chin up:
To remain joyful in a tough situation.

Kick The Bucket:
Die.

Kitty-corner:
Diagonally across. Sometimes called Catty-Corner as well.

Knee Jerk Reaction:
A quick and automatic response.

Knock On Wood:
Knuckle tapping on wood in order to avoid some bad luck.

Know the Ropes:
To understand the details.



L

Last but not least:
An introduction phrase to let the audience know that the last person mentioned is no less important than those introduced before him/her.

Lend Me Your Ear:
To politely ask for someone's full attention.

Let Bygones Be Bygones:
To forget about a disagreement or arguement.

Let Sleeping Dogs Lie:
To avoid restarting a conflict.

Let The Cat Out Of The Bag:
To share a secret that wasn't suppose to be shared.

Level playing field:
A fair competition where no side has an advantage.

Like a chicken with its head cut off:
To act in a frenzied manner.

liquor someone up:
To get someone drunk.

Long in the Tooth:
Old people (or horses).

Loose Cannon:
Someone who is unpredictable and can cause damage if not kept in check.



M

Make No Bones About:
To state a fact so there are no doubts or objections.

Method To My Madness:
Strange or crazy actions that appear meaningless but in the end are done for a good reason.

Mumbo Jumbo:
Nonsense or meaningless speech.

Mum's the word:
To keep quiet. To say nothing.



N

Nest Egg:
Savings set aside for future use.

Never Bite The Hand That Feeds You:
Don't hurt anyone that helps you.

New kid on the block:
Someone new to the group or area.

New York Minute:
A minute that seems to go by quickly, especially in a fast paced environment.

No Dice:
To not agree. To not accept a proposition.

No Room to Swing a Cat:
An unsually small or confined space.

Not Playing With a Full Deck:
Someone who lacks intelligence.



O

Off On The Wrong Foot:
Getting a bad start on a relationship or task.

Off The Hook:
No longer have to deal with a tough situation.

Off the Record:
Something said in confidence that the one speaking doesn't want attributed to him/her.

On Pins And Needles:
Anxious or nervous, especially in anticipation of something.

On The Fence:
Undecided.

On The Same Page:
When multiple people all agree on the same thing.

Out Of The Blue:
Something that suddenly and unexpectedly occurs.

Out On A Limb:
When someone puts themself in a risky situation.

Out On The Town:
To enjoy yourself by going out.

Over My Dead Body:
When you absolutely will not allow something to happen.

Over the Top:
Very excessive.



P

Pass The Buck:
Avoid responsibility by giving it to someone else.

Pedal to the metal:
To go full speed, especially while driving a vehicle.

Peeping Tom:
Someone who observes people in the nude or sexually active people, mainly for his own gratification.

Pick up your ears:
To listen very carefully.

Pig In A Poke:
A deal that is made without first examining it.

Pig Out :
To eat alot and eat it quickly.

Pipe Down:
To shut-up or be quiet.

Practice Makes Perfect:
By constantly practicing, you will become better.

Pull the plug:
To stop something. To bring something to an end.

Pulling Your Leg:
Tricking someone as a joke.

Put a sock in it:
To tell noisy person or a group to be quiet.



Q

Queer the pitch:
Destroy or ruin a plan.



R

Raincheck:
An offer or deal that is declined right now but willing to accept later.

Raining Cats and Dogs:
A very loud and noisy rain storm.

Ring Fencing:
Seperated usual judgement to guarantee protection, especially project funds.

Rise and Shine:
Time to get out of bed and get ready for work/school.

Rome Was Not Built In One Day:
If you want something to be completely properly, then its going to take time.

Rule Of Thumb:
A rough estimate.

Run out of steam:
To be completely out of energy.



S

Saved By The Bell:
Saved at the last possible moment.

Scapegoat:
Someone else who takes the blame.

Scot-free:
To escape and not have to pay.

Sick As A Dog:
To be very sick (with the flu or a cold).

Sitting Shotgun:
Riding in the front passenger seat of a car.

Sixth Sense:
A paranormal sense that allows you to communicate with the dead.

Skid Row:
The rundown area of a city where the homeless and drug users live.

Smell A Rat:
To detect somone in the group is betraying the others.

Smell Something Fishy:
Detecting that something isn't right and there might be a reason for it.

Son of a Gun:
A scamp.

Southpaw:
Someone who is left-handed.

Spitting Image:
The exact likeness or kind.

Start From Scratch:
To do it all over again from the beginning.



T

The Ball Is In Your Court:
It is your decision this time.

The Best Of Both Worlds:
There are two choices and you have them both.

The Bigger They Are The Harder They Fall:
While the bigger and stronger opponent might be alot more difficult to beat, when you do they suffer a much bigger loss.

The Last Straw:
When one small burden after another creates an unbearable situation, the last straw is the last small burden that one can take.

The Whole Nine Yards:
Everything. All of it.

Third times a charm:
After no success the first two times, the third try is a lucky one.

Tie the knot:
To get married.

Til the cows come home:
A long time.

To Make A Long Story Short:
Something someone would say during a long and boring story in order to keep his/her audience from losing attention. Usually the story isn't shortened.

To Steal Someone's Thunder:
To take the credit for something someone else did.

Tongue-in-cheek:
humor, not to be taken serious.

Turn A Blind Eye:
Refuse to acknowledge something you know is real or legit.

Twenty three skidoo:
To be turned away.



U

Under the weather:
Feeling ill or sick.

Up a blind alley:
Going down a course of action that leads to a bad outcome.

Use Your Loaf:
Use your head. Think smart.



V

Van Gogh's ear for music:
Tone deaf.

Variety Is The Spice Of Life:
The more experiences you try the more exciting life can be.



W

Wag the Dog:
A diversion away from something of greater importance.

Water Under The Bridge:
Anything from the past that isn't significant or important anymore.

Wear Your Heart On Your Sleeve:
To openly and freely express your emotions.

When It Rains, It Pours:
Since it rarely rains, when it does it will be a huge storm.

When Pigs Fly :
Something that will never ever happen.

Wild and Woolly:
Uncultured and without laws.

Wine and Dine:
When somebody is treated to an expensive meal.

Without A Doubt:
For certain.


X

X marks the spot:
A phrase that is said when someone finds something he/she has been looking for.



Y

You Are What You Eat:
In order to stay healthy you must eat healthy foods.

You Can't Judge A Book By Its Cover:
Decisions shouldn't be made primarily on appearance.

You Can't Take it With You:
Enjoy what you have and not what you don't have, since when you die you cannot take things (such as money) with you.

Your Guess Is As Good As Mine:
I have no idea.



Z

Zero Tolerance:
No crime or law breaking big or small will be overlooked.

Thursday, July 19, 2012

A System of Mental Arithmetic


THE SHORTEST SHORT-CUT
A System of Mental Arithmetic

by Oluf Nielsen

The purpose of this pamphlet is to promote an alert mind. As training for the mind, it is helpful in all studies, not only mathematics.
It does not interfere with the current prescribed courses of study and is no criticism of present instruction. It is a helpful addition to a student's mathematical ability.
If a student will memorize the squares of the numbers between 10 and 20 (only nine!), and read this pamphlet, it will give him the power to multiply large numbers such as 175 x 175.
175 x 175= (170 x 180) + (5 x 5)
= 30,625
275 x 275= (270 x 280) + (5 x 5)
= 75,625
The reason for 280 instead of 270 is due to changing the problem to an equation such as:
75²= (70 x 70) + (5 x 70) + (5 x 70) + (5 x 5)
= 4900 + 350 + 350 + 25
= 5625
By adding 10 to the second 70, the two center sections of 350 are eliminated and it becomes:
75²= (70 x 80) + (5 x 5)
= 5625
All numbers ending in 5 can be squared in this manner.
65²= (60 x 70) + (5 x 5)
= 4225
It is fast and easy!
The student will need to memorize the squares of the numbers from 10 to 20.
10² = 10 x 10 = 100
11² = 11 x 11 = 121
12² = 12 x 12 = 144
13² = 13 x 13 = 169
14² = 14 x 14 = 196
15² = 15 x 15 = 225
16² = 16 x 16 = 256
17² = 17 x 17 = 289
18² = 18 x 18 = 324
19² = 19 x 19 = 361
20² = 20 x 20 = 400

How to Find the Square of All Numbers to 100

Examples:
 82²= 80 x 80 + (80 + 82) (2)
= 6400 + 324
= 6724
 81²= 80 x 80 + (80 + 81) (1)
= 6400 + 161
= 6561
Center80²= 6400
 79²= 80 x 80 - (80 + 79) (1)
= 6400 - 159
= 6241
 78²= 80 x 80 - (80 + 78) (2)
= 6400 - 316
= 6084
Continuing this process:
 77²= 75 x 75 + (75 + 77) (2)
= 5625 + 304
= 5929
 76²= 75 x 75 + (75 + 76) (1)
= 5625 + 151
= 5776
Center75²= 5625
 74²= 75 x 75 - (75 + 74) (1)
= 5625 - 149
= 5476
 73²= 75 x 75 - (75 + 73) (2)
= 5625 - 296
= 5329

How to Multiply Any Two Numbers in Any Ten Group

For example (60 to 70):
If the units added = 10:
61 x 69= (6 x 7) (100) + (1 x 9)
= 4200 + 9
= 4209
62 x 68= (6 x 7) (100) + (2 x 8)
= 4200 + 16
= 4216
63 x 67= (6 x 7) (100) + (3 x 7)
= 4200 + 21
= 4221
64 x 66= (6 x 7) (100) + (4 x 6)
= 4200 + 24
= 4224
If the units added do not = 10, adjust to use units which = 10 and add or subtract the difference.
63 x 69= 61 x 69 + (2) (69)
= 4209 + 138
= 4347
71 x 77= 73 x 77 - (2) (77)
= 5621 - 154
= 5467

Multiplying by Comparative Measure Called the Use of the Bar

The bar of any number is the nearest ten to it. For example, the bar of 38 is 40 and the bar of 78 is 80.
If both numbers are under their bars, subtract a number which is equal to multiplier plus bar of multiplicand timesnumber under the bar from product of the two bars.
For example, 78 is 2 under its bar of 80.
78 (multiplicand) x 38 (multiplier)
78 x 38= 40 x 80 - (80 + 38) (2)
= 3200 - 236
= 2964
If both numbers are over their bars, add a number which is equal to multiplier plus bar of multiplicand times number over the bar to product of the two bars.
82 x 42= 80 x 40 + (42 + 80) (2)
= 3200 + 244
= 3444
79 x 39= 80 x 40 - (39 + 80) (1)
= 3200 - 119
= 3081
77 x 37= 80 x 40 - (37 + 80) (3)
= 3200 - 351
= 2849
If the numbers are both over or under the bar but not in equal amounts, adjust to make them equal and add or subtract the difference.
78 x 37= 77 x 37 + 37
= 2849 + 37
= 2886
If the multiplicand is under the bar and the multiplier is over the bar, then add the difference between the multiplier and the bar of the multiplicand.
78 x 42= 80 x 40 + (80 - 42) (2)
= 3200 + 76
= 3276
If the multiplicand is over the bar and the multiplier is under the barsubtract the difference between the multiplier and the bar of the multiplicand.
82 x 38= 80 x 40 - (80 - 38) (2)
= 3200 - 84
= 3116
A split bar is when one number is over the bar and the other is under.
Examples:
88 x 62= 90 x 60 + (90 - 62) (2)
= 5400 + 56
= 5456
Split Bar
92 x 58= 90 x 60 - (90 - 58) (2)
= 5400 - 64
= 5336
Split Bar
148 x 92= 150 x 90 + (150 - 92) (2)
= 13500 + 116
= 13616
Split Bar
148 x 88= 150 x 90 - (150 + 88) (2)
= 13500 - 476
= 13024
Both Under
152 x 92= 150 x 90 + (150 + 92) (2)
= 13500 + 484
= 13984
Both Over
Note: Always select the bar closest to the numbers to be multiplied.

How to Multiply Any Number by 33 1/3 or 25

To multiply by 33 1/3, as a short cut, multiply by 100 and divide by 3.
33 1/3 x 84 = 8400 / 3 = 2800
33 1/3 x 87 = 8700 / 3 = 2900
But if you multiply by 33 only, you subtract 1/100 of the answer or 28 or 29 respectively.
33 x 84= 8400 / 3 - 28
= 2800 - 28
= 2772
33 x 87= 8700 / 3 - 29
= 2900 - 29
= 2871
33 x 86= 8600 / 3 - 28
= 2866 - 28
= 2838
Note: Here remainders of 2 from 8600 / 3 were lost and were not needed.
To multiply by 25, multiply by 100 and divide by 4.
25 x 54 = 5400 / 4 = 1350

Mulitiplication by Formula

In high school algebra:
(4x) (2x) = 8x²
In college algebra:
The answer equals half the sum squared minus half the difference squared.
(4x) (2x)= (6x / 2)² - (2x / 2)²
= 9x² - x²
= 8x²
93 x 57= (150 / 2)² - (36 / 2)²
= 75² - 18²
= 5625 - 324
= 5301
766 x 534= (1300 / 2)² - (232 / 2)²
= 650² - 116²
= 422,500 - 13,456
= 409,044
75,500²= (75 x 76 x 1,000,000) + (5 x 5 x 10,000)
= 5,700,000,000 + 250,000
= 5,700,250,000
75,500 x 80,500= (156,000 / 2)² - (5,000 / 2)²
= 78,0000² - 2,500²
= 6,084,000,0000 - 6,250,000
= 6,077,750,000

When the student becomes inquisitive enough he will wonder what put the planets like our earth in orbit at 93,000,000 miles from the sun. What keeps it from being drawn into the sun?
If the north pole was not pointing towards the north star, would we have the four seasons?
At what speed do we travel to make the orbit in 365 1/4 days?
What would happen if the earth did not roll over 1,000 miles per hour establishing day and night divided in the 24 hours?
Would it work if it rolled at 500 miles per hour? Or would the nights be too cold and the days too hot for vegetation?
Wishing to know is the start of thinking. Only the drive to know will start the process. Out of more than 6,000,000 brain cells, some must be inactive. Let us call it cold storage.
Maybe with this mental arithmetic, we can get some of those cells out of cold storage!
 Oluf Nielsen, Author (1891–1967)
Council Bluffs, Iowa
Circa 1965
All copyrights reserved

Many job seekers walk into an interview ill-prepared, expecting the employer to ask all the questions.
Wrong move, says Ford R. Myers, author of "Get The Job You Want, Even When No One's Hiring," (John Wiley & Sons, 2009).
"Asking smart questions will help the job seeker sound articulate, well-prepared and genuinely interested in working for the organization," says Myers.
Myers recommends asking the following questions to find out as much as possible about the job and leave a good impression.



1. Can you give me more detail about the position's responsibilities?

1. Can you give me more detail about the position's responsibilities?

2. Where do you see this position going in the next few years?

2. Where do you see this position going in the next few years?
en321viaFlickr

3. How can I most quickly become a strong contributor within the organization?

3. How can I most quickly become a strong contributor within the organization?
usfbpsviaFlickr

4. What are the most challenging aspects of the job for which I am being considered?

4. What are the most challenging aspects of the job for which I am being considered?

5. How will my performance be evaluated, and at what frequency?

5. How will my performance be evaluated, and at what frequency?

6. What particular aspects about my background and experience interest you?

6. What particular aspects about my background and experience interest you?
scoviaFlickr

7. What makes you think I will be successful in this job? What causes you concern about my candidacy?

7. What makes you think I will be successful in this job? What causes you concern about my candidacy?

8. Now that we've had a chance to talk, how does my background measure up to the requirements of the job? To the other candidates?

8. Now that we've had a chance to talk, how does my background measure up to the requirements of the job?  To the other candidates?
jerineviaFlickr

9. Where are you in the hiring process? What's our next step?

9. Where are you in the hiring process? What's our next step?
usfbpsviaFlickr

10. If I don't hear from you within (time period), would it be okay to call you?

10. If I don't hear from you within (time period), would it be okay to call you?

Wednesday, June 20, 2012

trigraphs in c


trigraph" -- C Language" "


trigraph is a set of three characters that represents one character in the C character set. The set of trigraph sequences was defined in the ANSI Standard to allow users to use the full range of C characters, even if their keyboards do not implement the full C character set. Trigraph sequences are also useful with input devices that reserve one or more members of the C character set for internal use; e.g., the Hazeltine family of terminals, which reserves the tilde `~' as its escape character.
Each trigraph sequence is introduced by two question marks. The third character in the sequence indicates which character is being represented. The following table gives the set of trigraph sequences:
      _ T_ r_ i_ g_ r_ a_ p_ h  _ C_ h_ a_ r_ a_ c_ t_ e_ r
      _ S_ e_ q_ u_ e_ n_ c_ e _ R_ e_ p_ r_ e_ s_ e_ n_ t_ e_ d

         ??=        #
         ??(        [
         ??/        \
         ??)        ]
         ??'        ^
       ??<       {
         ??!        |
       ??>       }
         ??-        ~
The characters represented are the ones used in the C character set but not included in the ISO 646 character set. ISO 646 describes an invariant sub-set of the ASCII character set.
Trigraph sequences are interpreted even if they occur within a string literal or a character constant. Thus, strings that uses a literal ``??'' will not work the same as under a non-ANSI implementation of C. For example, the function call
     printf("Feel lucky, punk??!\n");
would print:
     Feel lucky, punk|
To print a pair of questions marks, use the escape sequence `\??'. For example:
     printf("Feel lucky, punk\??!\n");


The BASIC programming language was developed in 1965 by John G. Kemeny and Thomas E. Kurtz as a language for introductory courses in computer science. In 1988 they extended the language to make it modular and portable.




1. Introduction
True BASIC, C, Fortran, and Pascal are examples of procedural languages. Procedural languages change the state or memory of the machine by a sequence of statements. True BASIC is similar to F (a subset of Fortran 90) and has excellent graphics capabilities which are hardware independent. True BASIC programs can run without change on computers running the Macintosh, Unix, and Windows operating systems. We will consider version 3.0 (2.7 on the Macintosh) of True BASIC. Version 5 includes the ability to build objects such as buttons, scroll bars, menus, and dialog boxes. However, because we wish to emphasize the similarity between True BASIC and other procedural languages such as C, F, and Java, we do not consider these features.
There is no perfect programming language (or operating system) and users should be flexible and choose the appropriate language to accomplish their goals. Former students who were well grounded in True BASIC have had no trouble learning C, F, and Java quickly.
This tutorial is based on the text, Introduction to Computer Simulation Methods, by Harvey Gould and Jan Tobochnik. The features of True BASIC which are common to other procedural languages are emphasized.
To illustrate the nature of True BASIC, we first give a program that multiplies two numbers and prints the result:
PROGRAM product
! taken from Chapter 2 of Gould & Tobochnik
LET m = 2                         ! mass in kilograms
LET a = 4                         ! acceleration in mks units
LET force = m*a                   ! force in Newtons
PRINT force
END
The features of True BASIC included in the above program include: The first statement is an optional PROGRAM header. The inclusion of a program header is good programming style.
 Comment statements begin with ! and can be included anywhere in the program.
 PROGRAM, LET, PRINT, and END are keywords (words that are part of the language and cannot be redefined) and are given in upper case. The case is insignificant (unlike C, F, and Java). The DO FORMATcommand converts keywords to upper case.
 The LET statement causes the expression to the right of the = sign to be evaluated and then causes the result to be assigned to the left of the = sign. (The LET statement reminds us that the meaning of the = symbol is not the same as equals.) It is not necessary to type LET, because the DO FORMAT command automatically inserts LET where appropriate. The LET statement can be omitted if the OPTION NOLET statement is included.
 True BASIC does not distinguish between integer numerical variables and floating point numerical variables and recognizes only two types of data: numbers and strings (characters). The first character of a variable must be a letter and the last must not be an underscore.
 The PRINT statement displays output on the screen.
 The last statement of the program must be END.
We next introduce syntax that allows us to enter the desired values of m and a from the keyboard.
PROGRAM product2
INPUT m
INPUT prompt "acceleration a (mks units) = ": a
LET force = m*a                       ! force in Newton's
PRINT "force (in Newtons) ="; force
END
Note the difference between the INPUT and INPUT prompt statements and the simple modification of the PRINT statement. What happens if you replace the semicolon after the expression in the PRINT statement by a comma? Modify the program so that it adds, subtracts, and divides two numbers.2. Loop structuresTrue BASIC uses a FOR or a DO construct to execute the same statements more than once. An example of a FOR loop follows:
PROGRAM series
! add the first 100 terms of a simple series
! True BASIC automatically initializes variables to zero,
! but other languages might not.
LET sum = 0
FOR n = 1 to 100
    LET sum = sum + 1/(n*n)
    PRINT n,sum
NEXT n
END
 The use of the FOR loop structure allows a set of statements to be executed a predetermined number of times. The index or control variable (n in Program series) monitors the number of times the loop has been executed. The FOR statement specifies the first and last value of the index and the amount that the index is incremented each time the NEXT statement is reached. Unless otherwise specified, the index is increased by unity until the index is greater than its last value in which case the program goes to the statement after the NEXT statement. In Program series, the index n assumes the values 1 through 100. True BASIC treats n as an integer variable. The block of statements inside the loop is indented for clarity. Use the DO FORMAT command to indent loops automatically.
 The order of evaluation follows the mathematical conventions shared by all computer languages. Exponentiations are performed first, followed by multiplications and divisions from left to right. Parentheses should be used whenever the result might be ambiguous to the reader. The parentheses in the statement, LET sum = sum + 1/(n*n), are included for clarity.
 All unassigned variables are automatically initialized to zero. Because C, F, and Java do not, it is recommended that variables such as sum in Program series be initialized explicitly.
In many cases the number of repetitions is not known in advance. An example of a DO loop follows:
PROGRAM series_do
! illustrate use of DO LOOP structure
LET sum = 0
LET n = 0
LET relative_change = 1           ! choose large value
DO while relative_change > 0.0001
   LET n = n + 1
   LET newterm = 1/(n*n)
   LET sum = sum + newterm
   LET relative_change = newterm/sum
   PRINT n,relative_change,sum
LOOP
END
Note the use of the DO while loop structure to repeat the sum until the specified condition is no longer satisfied. An example of the DO until loop structure is illustrated in Program example_f.3. Conditional statementsThe IF statement lets a program branch to different statements depending on the outcome of previous computations. An example of the use of the IF statement follows:
PROGRAM decision1
LET x = 0
DO while x < 20
   LET x = x + 1
   IF x <= 10 then
      LET f = 1/x
   ELSE
      LET f = 1/(x*x)
   END IF
   PRINT x,f
LOOP
END
The IF construct is a compound statement which begins with IF ... then and ends with END IF. The sequence of statements (a block) inside the IF construct is indented for clarity (done automatically by the DO FORMAT command). An example of the IF statement with two or more branches is given by:
PROGRAM decision2
LET x = 0
DO while x <= 30
   IF x = 0 then
      LET f = 0
   ELSEIF x <= 10 then
      LET f = 1/x
   ELSEIF x <= 20 then
      LET f = 1/(x*x)
   ELSE
      LET f = 1/(x*x*x)
   END IF
   PRINT x,f
   LET x = x + 1
LOOP
END
Any number of ELSEIF statements may be used in an IF structure, and IF statements may be nested.The decisions of an IF structure are based on (logical or Boolean) expressions which are either true or false. A logical expression is formed by comparing two numerical or two string expressions by a relational operator. These operators are given in Table 1.

Table 1. Summary of relational operators.
relationoperator
equal=
less than<
less than or equal<=
greater than>
greater than or equal>=
not equal<>
If all the choices in the decision structure are based on the value of a single expression, it is sometimes convenient to use a SELECT CASE structure.
Although True BASIC explicitly recognizes only two kinds of variables, numeric and string, it implicitly distinguishes between floating point (real) and integer numeric variables. For example, the variable x in Program decision2 is treated as an integer variable and hence stored with infinite precision; the variable f is treated as a real variable and stored to 14 to 16 decimal places depending on the computer. Arithmetic with numbers represented by integers is exact, but arithmetic operations which involve real numbers is not. For this reason, decision statements should involve comparisons of integer variables rather than floating point variables.
C and Fortran 90 support the WHILE statement, but F does not. A program equivalent to Program decision2 is given in the following:
PROGRAM decision3
LET x = 0
DO
   LET x = x + 1
   IF x <= 10 then
      LET f = 1/x
   ELSE
      LET f = 1/(x*x)
   END IF
   PRINT x,f
   IF x = 20 then
      EXIT DO                  ! note syntax
   END IF
LOOP
END
4. Subprograms and local and shared variables
dummy variables functions random number sequences
It is convenient to divide a program into smaller units consisting of a main program and subprograms consisting of subroutines and functions. Subprograms are called from the main program or other subprograms. As an example, the following program adds and multiplies two numbers which are inputed from the keyboard.
PROGRAM tasks            ! illustrate use of subroutines
! note how variables are passed
CALL initial(x,y)                 ! initialize variables
CALL add(x,y,sum)                 ! add two variables
CALL multiply(x,y,product)
PRINT "sum ="; sum, "product ="; product
END                               ! end of main program

SUB initial(x,y)
    INPUT x
    INPUT y
END SUB

SUB add(x,y,sum)
    LET sum = x + y
END SUB

SUB multiply(x,y,product)
    LET product = x*y
END SUB
 Program tasks is an example of a modular program, a program which is divided into separate tasks each of which can be written and tested separately. A complete program contains a main program consisting of a series of calls to subprograms. Subroutines are invoked by the CALL statement. Subroutines and functions are called from the main program or other subprograms. A subroutine is defined by a SUB statement; the end of a subroutine is denoted by END SUB. We use only external subroutines and functions. External program units are defined in any order after the END statement of the main program.
 A subroutine is a separate program unit with its own local variables, that is, the variables in the main program and in each external subroutine and function are available only to the program subunit. A variable name represents a memory location in the computer. If the same variable name is used in two program units, the name represents two different memory locations.
The most common method for subroutines to pass information to the main program and to other subroutines is via arguments in the subroutine calls. In Program tasks the variables x, y, sum, and product are passed in this way. (It is a little misleading to say that variable names are passed to a subroutine. More precisely, the variable names are not passed, but rather the memory location in the computer is passed. The variable name is simply a label that identifies the memory location.)
In Program no_pass the variable name x is used in the main program and in SUB add_one, but is not passed. Convince yourself that the result printed for x in the main program is 10. What is the value of x in SUB add_one?
PROGRAM no_pass
LET x = 10             ! local variable name x defined in main program
CALL add_one
PRINT x
END

SUB add_one
    ! variable name x not passed
    LET x = x + 1      ! local variable name defined in subroutine
END SUB
What are the values of x and y if SUB add_one in Program pass is written in the following form?
PROGRAM pass
LET x = 10
LET y = 3
CALL add_one(x)
CALL add_one(y)
PRINT x,y
END

SUB add_one(s)              ! example of the use of dummy arguments
    LET s = s + 1
END SUB
 The variable name in the subroutine declaration need not match the name used in calling the subroutine. We call the declaration variable name a "dummy variable," because it may not actually be used in the program execution. It is only necessary that the number of variables in the declaration equal the number in the calling of a subroutine. Another way of passing information in True BASIC is discussed later.
An example of the use of a function is given in the following:
PROGRAM example_f
! example of use of external function
DECLARE DEF f
LET delta = 0.01                  ! incremental increase
LET sigma2 = 1                    ! variance 
LET x = 0                         ! initialize variables even though unnecessary
DO
   PRINT x,f(x,sigma2)
   LET x = x + delta
LOOP until key input
END

DEF f(x,sigma2)
    ! define Gaussian function with zero mean and variance sigma2
    LET f = (2*pi*sigma2)^(-0.5)*exp(-x*x/(2*sigma2))
END DEF
Note that functions do not change the values of arguments to them. Definitions are not limited to a single line. One way to stop a program is to have the user hit any key as shown by the use of the key input statement in Program example_f.
 The exponentiation operator is ^.
 The quantity pi (the area of a circle with unit radius) is predefined. Its use is illustrated in Program example_f. (Strictly speaking, pi is a function which has no arguments and whose value is pi.)
True BASIC has many intrinsic (built-in) functions. Some of the more frequently used mathematical functions are given in Table 2.
Table 2. Useful mathematical functions.
notationfunction
abs(x)absolute value
sqr(x)square root
exp(x)exponential function
log(x)natural logarithm
log10(x)logarithm base 10
sin(x)sine function
cos(x)cosine function
tan(x)tangent function
int(x)integer part
mod(x,y)remainder when x is divided by y
max(x,y)larger of x and y
min(x,y)smaller of x and y
remainder(x,y)mod(x,y) - y
If you are uncertain how a particular function works, write a little program to test it. For example, what is the value of mod(10,3)? What about mod(-10,3)? What is the difference between the MOD and the REMAINDER functions?
True BASIC includes several useful built-in functions besides pi. One of the most useful ones is rnd which produces a random number that is uniformly distributed between zero and one. The same sequence of random numbers appears each time the program is run unless the function RANDOMIZE is called before the rnd function is used. An example of a program which generates random sequences of integers between 1 and N is given below.
PROGRAM random
RANDOMIZE
LET N = 100
FOR i = 1 to N
    LET integer = int(N*rnd) + 1
    PRINT integer;
NEXT i
END
Because the effect of the int function is to round the output of rnd down to its nearest integer, it is necessary to add 1.Although it is a good idea to write your own random number generator using an algorithm that you have tested on the particular problem of interest, it is convenient to use the rnd function when you are debugging a program or if accuracy is not important.
5. ArraysAn array variable is a data structure consisting of an ordered set of elements of the same data type. One advantage of arrays is that they allow for the logical grouping of data of the same type, for example the x and y coordinates of a particle. The dimension of an array and the passing of arrays to a subroutine is illustrated in Program vector:
PROGRAM vector                    ! illustrate use of arrays
DIM a(3),b(3)                     ! arrays defined in DIM statement
CALL initial(a(),b())
CALL dot(a(),b())
CALL cross(a(),b())
END

SUB initial(a(),b())
    LET a(1) = 2
    LET a(2) = -3
    LET a(3) = -4
    LET b(1) = 6
    LET b(2) = 5
    LET b(3) = 1
END SUB

SUB dot(a(),b())
    LET dot_product = 0
    FOR i = 1 to 3
        LET dot_product = dot_product + a(i)*b(i)
    NEXT i
    PRINT "scalar product = "; dot_product
END SUB

SUB cross(r(),s())
    ! arrays can be defined in main program or subroutine
    ! note use of dummy variables
    DIM cross_product(3)
    FOR component = 1 to 3
        LET i = mod(component,3) + 1
        LET j = mod(i,3) + 1
        LET cross_product(component) = r(i)*s(j) - s(i)*r(j)
    NEXT component
    PRINT
    PRINT "three components of the vector product:"
    PRINT " x "," y "," z "
    FOR component = 1 to 3
        PRINT cross_product(component),
    NEXT component
END SUB
The properties of arrays in True BASIC include: Arrays are defined in a DIM statement and the total number of elements of an array is given in parentheses. The array variables a and b in the main program and the array variables r and s in SUB cross are examples of one-dimensional arrays.
 The lower and upper limit of each subscript in an array can be specified; the default lower limit is 1. Examples of other limits are DIM r(0 to 2) and DIM s(-3 to 3). A colon may be used instead of TO in the DIM statement, for example, DIM r(0:2) and DIM s(-3:3). The arguments in a DIM statement must be numbers, not variables.
 An element of an array is specified by its subscript value. Arrays can be passed to a subroutine or a function, with empty parentheses and commas used to indicate the dimension of the array.
 The same name cannot be used for both an array variable and for another type of variable.
Because the address of the first element of the array is passed, rather than the entire array, there is no memory or speed penalty when arrays are passed to a subroutine. True BASIC has many intrinsic matrix operations which are similar to the operations in F.
6. Input/output
SET CURSORPRINT USINGGET KEYGET MOUSEFilesREAD/DATA statements
The PRINT statement displays output on the screen. Some simple extensions of the PRINT statement include
PRINT "x","y","z"
PRINT x,y,z
PRINT                     ! skip line
PRINT "time ="; t
PRINT tab(7);"time";tab(17);"position";tab(28);"velocity"
 True BASIC prints at the current cursor position. The function tab(x) moves the cursor to column x.
 The cursor may be moved by the SET CURSOR statement
SET CURSOR 10, 20            ! row, column
which moves the cursor to row 10 and column 20. SET CURSOR 1,1 moves the cursor to the upper left corner. Because different computers have different numbers of rows and columns, the statement
ASK SET CURSOR max_row,max_col
sets max_row to the largest row number and max_col to the maximum column number.
Formatted output
If you need to print output to greater accuracy or in a different format than the default used by True BASIC, use the 
PRINT using statement.
PRINT using "####.###": t,x,v  ! output occupies 8 spaces including decimal point
PRINT using "----.###": t,x,v  ! - prints number with leading space or minus sign
PRINT using "--%%.###": t,x,v  ! % prints leading zeroes as '0'
Try various values of t, x, and v to see the nature of the output. For example, try t = 15.5, x = -3.222222, and v = 1.Key input
The statement GET KEY k waits until the user presses a key, then converts that key into its corresponding number and then converts this number to the variable k.
PROGRAM space_bar
DO
   GET KEY k
   PRINT k
LOOP until k = 32                 ! pressing space bar exits loop
END
We have already given an example of the use of the logical expression 
key input.Mouse
The use of the GET MOUSE statement is illustrated in Program mouse:
PROGRAM mouse
DO
   ! return current x and y window coordinates and state of mouse
   GET MOUSE x,y,s
   IF s = 1 then
      PRINT "button down",x,y
   ELSE IF s = 2 then
      PRINT "button clicked",x,y
   ELSE IF s = 3 then
      PRINT "button released",x,y
   END IF
LOOP
END
The variable s is the state of the mouse when the cursor is at position (x,y). The possible values of the status are
s = 0mouse button not pressed
s = 1mouse button held down while dragging
s = 2mouse button clicked at (x,y)
s = 3mouse button released at (x,y)
Files
The following program illustrates how to open a text file, write to the file, close the file, and read the file.
PROGRAM single_column
! save data in a single column
! file$ example of string variable
INPUT prompt "name of file for data? ": file$
! channel number #1 associated with file and can be passed to
! subroutines
! various options may be specified in OPEN statement
! access output: write to file only
! create newold: open file if exists, else create new file
OPEN #1: name file$, access output, create newold
! True BASIC does not overwrite data in a text file
! ERASE #1                          ! erase contents of file
! RESET #1: end   ! allows data to be added to end of file
FOR i = 1 to 4
    LET x = i*i
    PRINT #1: x                   ! print column of data
NEXT i
CLOSE #1
! channel # irrelevant if only one channel open at a time
OPEN #2: name file$, access input
FOR i = 1 to 4
    INPUT #2: y                   ! print column of data
    PRINT y
NEXT i
! files automatically closed when program terminates
CLOSE #2                          ! not necessary but good practice
END
Program single_column uses a 
string or character variable for the name of the file. The writing of files with multiple columns is more complicated and is illustrated in the following.
file$ = "config.dat"
OPEN #1: name file$,access output,create new
PRINT #1: N
PRINT #1: L
! comma added between inputs on the same line so that file
! can be read by True BASIC
FOR i = 1 to N
   PRINT #1, using "----.######, ----.######": x(i),y(i)
NEXT i
CLOSE #1
! next illustrate how to read file.
OPEN #1: name file$, access input
INPUT #1: N
INPUT #1: L
FOR i = 1 to N
   INPUT #1: x(i),y(i)
NEXT i
It is necessary to separate columns by a comma, an annoying feature of True BASIC. There are many variations on the open statement, but the above example is typical.READ/DATA statements
One way to incorporate data into a program from a file. Another way to store information within a program is by using the DATA and READ statements as illustrated in Program example_data.
PROGRAM example_data
DIM x(6)
DATA 4.48,3.06,0.20,2.08,3.88,3.36
FOR i = 1 to 6
    READ x(i)                ! reads input from DATA statement
NEXT i
END
7. GraphicsThe platform independent graphics statements of True BASIC are sufficiently powerful to do useful animations and visualizations. It is recommended that a separate plotting program be used for making presentation graphs and fits to data.
Core statementsAspect ratioMultiple windowsAnimation
A graphics screen is covered by a grid of pixels. The number of pixels is hardware dependent. In True BASIC the number of pixels is irrelevant because the mapping of the absolute values of the coordinates to the device coordinates or pixels is done by True BASIC. The first step is to specify the range of coordinates which are to be plotted. The statement
SET WINDOW xmin, xmax, ymin, ymax
determines the minimum and maximum x (horizontal) and y (vertical) coordinates. The statement
PLOT POINTS: x,y;
draws a point at (x,y) in the current window coordinates. The statement
PLOT LINES: x1,y1; x2,y2;
draws a line between (x1,y1) and (x2,y2). Program plot_f uses these statements to draw a set of axes and plot the function T(t) = Ts - (Ts - T0) e-rt.
PROGRAM plot_f                     ! plot analytical solution
CALL initial(t,tmax,r,Ts,T0)
CALL set_up_window(t,tmax,Ts,T0)
CALL show_plot(t,tmax,r,Ts,T0)
END

SUB initial(t,tmax,r,Ts,T0)
    LET t = 0
    LET T0 = 83                   ! initial coffee temperature (C)
    LET Ts = 22                   ! room temperature (C)
    INPUT prompt "cooling constant r = ": r
    INPUT prompt "duration = ": tmax   ! time (minutes)
    CLEAR
END SUB

SUB set_up_window(xmin,xmax,ymin,ymax)
    LET mx = 0.01*(xmax - xmin)   ! margin
    LET my = 0.01*(ymax - ymin)
    SET WINDOW xmin - mx,xmax + mx,ymin - my,ymax + my
    ! default background color black on all computers except Macintosh
    PLOT xmin,ymin; xmax,ymin     ! abbreviation for PLOT LINES:
    PLOT xmin,ymin; xmin,ymax
END SUB

SUB show_plot(t,tmax,r,Ts,T0)
    DECLARE DEF f                 ! declare use of external function
    SET COLOR "red"
    DO while t <= tmax
       PLOT t,f(t,r,Ts,T0);       ! abbreviation for PLOT LINES
       LET t = t + 0.1
    LOOP
END SUB

DEF f(t,r,Ts,T0)
    LET f = Ts - (Ts - T0)*exp(-r*t)
END DEF
The program uses a separate subroutine to set up the screen and another to plot the function. PLOT x,y; is an abbreviation of PLOT POINT x,y.
Program simple_map uses the SET WINDOW, PLOT, BOX LINES and ASK MAX COLOR statements to help visualize the trajectory of a two-dimensional dynamical system. A summary of the some of the important graphics statements is given in Table 3.


Table 3. Summary of core True BASIC graphics statements.
SET BACKGROUND COLOR "black"
SET WINDOW xmin,xmax,ymin,ymaxdefault window coordinates are 0,1,0,1
PLOT POINTS: x,yabbreviation is PLOT x,y
PLOT LINES: x1,y1; x2,y2;
PLOTstart a new curve
PLOT AREA: 1,1;2,1;2,2draw filled triangle
BOX LINES xmin,xmax,ymin,ymaxdraw rectangle
BOX AREA xmin,xmax,ymin,ymaxdraw filled rectangle
BOX CLEAR xmin,xmax,ymin,ymaxerase rectangle
BOX CIRCLE xmin,xmax,ymin,ymaxdraw inscribed circle (or ellipse)
ASK MAX COLOR mcmc is number of foreground colors
SET COLOR "red"colors include green, blue, brown, magenta, and white
CLEARerase contents of current window
FLOOD x,yfill enclosed region with current foreground color
Aspect Ratio
When is a circle not a circle? Run the following program and find out.
PROGRAM no_circle
LET r = 1                         ! radius of circle
SET WINDOW -r,r,-r,r
SET COLOR "blue"
BOX CIRCLE -r,r,-r,r
! FLOOD 0,0: start from the point 0,0 and color continuous pixels 
! until boundary of region is reached
FLOOD 0,0
END
The problem is that few computer screens are square and have the same number of pixels in the horizontal and vertical direction. Moreover, it is possible to define 
multiple windows whose shape is arbitrary. Sometimes it is essential that a circle really appear circular on the screen. In this case we must correct for the aspect ratio of the screen as done in the following program.
PROGRAM circle
LET r = 1                         ! radius of circle
CALL compute_aspect_ratio(r,xwin,ywin)
SET WINDOW -xwin,xwin,-ywin,ywin
SET COLOR "blue"
BOX CIRCLE -r,r,-r,r              ! draw circle
END

SUB compute_aspect_ratio(r,x,y)
    LET m = 0.1*r                 ! margin
    LET size = r + m
    ! px, py: # pixels in horizontal and vertical direction
    ASK PIXELS px,py
    IF px > py then
       LET aspect_ratio = px/py
       LET x = aspect_ratio*size
       LET y = size
    ELSE
       LET aspect_ratio = py/px
       LET x = size
       LET y = aspect_ratio*size
    END IF
END SUB
Note the use of the ASK PIXELS statement.
Multiple windows
So far we have used the entire screen for the default window. The following program illustrates how to use the OPEN statement to use a portion of the screen, make multiple windows, and choose a particular window. Note that each window has an associated channel number and properties such as its own coordinate system and plot color.
PROGRAM multiple_windows
! note passing of channel numbers
CALL initial(#1,#2)               ! initialize windows
CALL show(#1)
CALL show(#2)
END

SUB initial(#1,#2)
    OPEN #1: screen 0,0.5,0,1     ! left-half of screen
    SET WINDOW 0,1,0,1
    SET COLOR "green"
    OPEN #2: screen 0.5,1,0,1     ! right-half of screen
    SET COLOR "red"
    SET WINDOW 0,1,0,1
END SUB

SUB show(#9)
    WINDOW #9                     ! note use of dummy variable
    FOR i = 1 to 100
        PLOT rnd,rnd;
    NEXT i
END SUB
Animation
To make animations, we can store screen images as a 
string variable and display them again without the need for additional calculation. The following program illustrates the use of the BOX KEEP, BOX CLEAR, and BOX SHOW statements to create the illustrate the illusion of motion across the screen.
PROGRAM animation
SET WINDOW 1,10,1,10
SET COLOR "red"
BOX AREA 1,2,1,2             ! draw shape
BOX KEEP 1,2,1,2 in box$     ! store shape in string variable box$
CLEAR
LET x = 1
DO while x < 10
   BOX CLEAR x,x+1,5,6       ! erase shape
   LET x = x + 0.1
   BOX SHOW box$ at x,5      ! redraw shape at different location
   PAUSE 0.01                ! choose delay
LOOP
END
Another example of the use of animation is shown in Program pendula.8. String variablesAs mentioned, True BASIC recognizes only two types of variables, numeric and strings. A string variable may be any combination of characters. String variables end in a dollar sign ($). A string constant is any list of characters enclosed in quotation marks. An example of an assignment of a string variable is
LET file_name$ = "config.dat"
A program illustrating the most common operations on string variables follows:
PROGRAM string
LET a$ = " "
LET b$ = "good"
PRINT b$
LET b$ = b$ & a$ & "morning"     ! & for concatenation
PRINT b$
LET c$ = b$[1:4]                  ! extract substring
PRINT c$
END
True BASIC has many useful string handling functions, some which are summarized in Table 4.
Table 4. Useful string handling functions.
notationfunction
len(x$)number of characters in x$
pos(x$,a$,c)first occurrence of a$ in x$ at or after character number c
lcase$(x$)convert letters to lower case
ucase$(x$)convert letters to upper case
trim$(x$)remove leading and trailing blanks
ltrim$(x$)remove leading blanks
rtrim$(x$)remove trailing blanks
The function str$ converts a number to a string. The function val converts a string to a number. An example of the use of str$ is given in the following program.
PROGRAM read_file
! open n successive files
LET n = 20
FOR i = 1 to n
    LET si$ = str$(i)
    LET file_name$ = "config" & si$ & ".dat"
    OPEN #i: name file_name$, access output, create newold
    PRINT #i: file_name$
    PRINT file_name$
    CLOSE #i
NEXT i
END
9. Advanced topics
RecursionGlobal variablesStrong typingmodulesSelect caseMatrix operations
Recursion
A simple example of a recursive definition is the factorial function
factorial(n) = n! = n(n-1)(n-2) ... 1
A recursive definition of the factorial is
factorial(n) = n factorial(n-1)
A program that closely parallels the above definition follows.
PROGRAM n!
DECLARE DEF f
LET n = 11
PRINT "n! ="; f(n)
END PROGRAM

DEF f(n)
    IF n <= 0 then
       LET f = 1
    ELSE
       LET f = n*f(n-1)
    END IF
END DEF
Global variables
So far we have shared information between subprograms by using a parameter list. Another way to share information is by declaring variables to be PUBLIC. An example illustrates its use.
PROGRAM show_public
PUBLIC L,spin(3,3)
CALL initial
FOR y = 1 to L
    FOR x = 1 to L
        PRINT spin(x,y);
    NEXT x
    PRINT
NEXT y
END

SUB initial
    DECLARE PUBLIC L,spin(,)
    LET L = 3
    FOR y = 1 to L
        FOR x = 1 to L
            IF rnd < 0.5 then
               LET spin(x,y) = 1
            ELSE
               LET spin(x,y) = -1
            END IF
        NEXT x
    NEXT y
END SUB
Strong typing
Unlike C, F, and Java, True BASIC does not require variables to be declared before they can be used. The enforced declaration of variables is called strong typing and can be "turned on" in True BASIC by using the OPTION TYPO statement. This statement requires all variables to be declared as either LOCAL, PUBLIC or passed. Public variables are not passed in the arguments of the subroutines.
PROGRAM show_public
OPTION TYPO
PUBLIC L,spin(3,3)
LOCAL x,y
CALL initial
FOR y = 1 to L
    FOR x = 1 to L
        PRINT spin(x,y);
    NEXT x
    PRINT
NEXT y
END

SUB initial
    DECLARE PUBLIC L,spin(,)
    LOCAL x,y
    LET L = 3
    FOR y = 1 to L
        FOR x = 1 to L
            IF rnd < 0.5 then
               LET spin(x,y) = 1
            ELSE
               LET spin(x,y) = -1
            END IF
        NEXT x
    NEXT y
END SUB
Modules
A module is a library of external subprograms. If you are ready to use a module, you are ready to learn another procedural language such as 
F which uses modules more effectively. An example of a True BASIC program which uses a module follows.
PROGRAM cool
! numerical solution of Newton's law of cooling
LIBRARY "common"
DECLARE PUBLIC r,t,dt,tmax,nshow,T_coffee
CALL output
LET counter = 0
DO
   IF (t >= tmax) then
      EXIT DO
   END IF
   CALL Euler
   LET counter = counter + 1      ! number of iterations
   IF (mod(counter,nshow) = 0) then
      CALL output
   END IF
LOOP
DO
LOOP until key input
END
The module "common" is in a separate file with the same name. PUBLIC statements determine which variables may be accessed from outside the module. SHARE statements determine the variables that are available to all subprograms within the module, but not outside the module.
MODULE common
    PUBLIC r,t,dt,tmax,nshow,T_coffee
    SHARE T_room

    ! initialize variables
    LET t = 0.0                   ! time
    LET T_coffee = 82.3           ! initial coffee temperature (C)
    LET T_room = 17.0             ! room temperature (C)
    LET r = 0.2
    LET dt = 0.01
    LET tmax = 1
    LET tshow = 0.1
    LET nshow = int(tshow/dt)

    SUB Euler
        LET change = -r*(T_coffee - T_room)*dt
        LET T_coffee = T_coffee + change
        LET t = t + dt
    END SUB

    SUB output
        IF t = 0 then
           PRINT
           PRINT  "time","T_coffee","T_coffee - T_room"
           PRINT
        END IF
        PRINT t,T_coffee,T_coffee - T_room
    END SUB

END MODULE
Select case
If all the choices in the decision structure are based on the value of a single expression, it is sometimes convenient to use a SELECT CASE structure instead of multiple ELSEIF statements. An example of the use of the SELECT CASE structure in the context of a two-dimensional random walk follows:
LET direction = int(4*rnd) + 1
SELECT CASE direction
CASE 1
     LET x = x + 1
CASE 2
     LET x = x - 1
CASE 3
     LET y = y + 1
CASE 4
     LET y = y - 1
CASE else
     PRINT "error"
END SELECT
Matrix operations
True BASIC has many operations which operate on an entire array at once. MAT READ, MAT INPUT, and MAT PRINT have obvious meanings. Arrays in which all the elements are the same may be established as follows:
DIM usave(0:21)
MAT usave = 1.0
Matrix arithmetic such as adding matrices and dot products can be done as illustrated in the following program. Add some MAT PRINT statements to check the results.
PROGRAM example_matrix
! illustrate simple matrix arithmetic
DIM A(4),B(4),C(4),S(2,2),T(2,2),SI(2,2)
MAT A = 1
MAT B = 2*A
MAT C = A + B
MAT PRINT A,B,C
LET dot_product = dot(A,B)        ! dot product of A and B
MAT C = A*B                       ! matrix product
DATA 1,3,4,8
MAT READ S
MAT PRINT C,S
MAT T = Trn(S)                    ! transposed matrix
MAT SI = Inv(S)                   ! inverse matrix
MAT PRINT T,SI
! check that matrix of most recently inverted matrix is not too small
print det
END
True BASIC also allows arrays to be redimensioned in a way similar to the use of the allocate and deallocate statements in 
Fortran 90. But if you have read this far, you are ready to learn Fortran and C.