Both articles a and an are used:

before a singular noun when it is mentioned for the first time and represents no particular person or thing:

I need a passport.
They live in a house.
I have to buy an umbrella.

also before a noun which is used as an example of a class of things.

A child needs love.
A responsible person must be insured.

a and an is omitted before

plural forms (Cats are extremely independent.)

uncountable nouns (Do you need money?)

names of meals (I have breakfast at 7 a. m.)

the is used for singular and plural

the girl
the girls

1) the is used before a noun which has become definite as
a result of being mentioned a second time:

John has bought a car. The car cost him 25, 000$

2) the is used before a noun which has become definite by the addition of a phrase or clause:

the woman in black
the girl I am in love with

3) the is used before a noun which can represent only one particular thing:

Mum is in the kitchen.
Pass the salt, please.

4) the is used before superlatives and first, second etc.

the first year of…
the best friend

5) the is used before a noun to represent a class of people, animals or things:

The dolphin is in danger of becoming extinct.
The television has completely changed our lives.
The small shopkeeper is finding life more and more difficult.
(however, man, used to represent the human race, has no article)

6) the + adjective represents a class of people

the blind
the dead
the young

7) the is used before certain proper names of seas, rivers, groups of islands, chains of mountains, plural names of countries, deserts, regions:

the Atlantic
the Vistula
the Azores
the Himalayas
the Philippines
the Sahara
the Crimea

8) the is used before names consisting of noun + of + noun

the Cape of Good Hope
the United States of America

9) the is used before musical instruments:

the piano
the flute

The definite article the is not used :

before abstract nouns (Men fear death.)

before names of games ( I can’t play tennis.)

in a number of common expressions:

to school at school from school in/to class

to/at/from college/university to/in/from church

to/into/in/out of prison/hospital/bed to/at/from work

to/at sea to/in/from town at/from home

for breakfast at lunch to dinner at night

by car/bus/bicycle/plane/train/tube/boat

on foot to go to sleep

when the above expressions are used with articles,
they have special meanings:

He is in prison. (as a prisoner)
He is in the prison.(perhaps as a visitor)

To sum it up remember three golden rules:

1) Do not use the to talk about things in general (NOT the life is hard).

2) Do not use singular countable nouns without articles (NOT I have car).

3) Use a/an to say what people’s jobs are (NOT He is teacher).