Accidentals are notes which are the chromatic alternatives of the usual notes in a piece and which appear only temporarily. To indicate an accidental, an accidental sign (sharp sign which looks like #, flat sign which looks like b, natural sign which looks like ╘╕, occasionally double sharp sign which looks like ×, double flat sign which looks like bb) is notated before the note. For example a sharp sign # before an A note indicates that the note to be played is A-sharp.
An accidental sign is valid until the end of the bar/measure where the accidental is notated in and is valid on the notes with the same name on all octaves of the instrument, if there is no other accidental sign on the same note(s). In the example, until the end of the bar/measure, all A notes on any octave will be read as A-sharp without notating the # sign again. It is usual to notate the notes with the same name on the other octaves with the accidental sign also to clearly indicate this (in the example, a # sign is also written before the A(-sharp) one octave higher or lower etc.). To reset sharp or flat notes to natural notes in the same bar/measure, the natural sign ╘╕ is notated before the note. It is also valid until the end of the bar/measure and on all octaves.
From the next bar/measure, the default is that usual notes are played again. If the accidental was not reset in the preceding bar, the first reset note in the next bar is often notated with the default sign also to clearly indicate this (in the example, the first A-natural in the next bar is also written with a ╘╕ sign). If the same accidental appears again, the accidental sign must be notated as normal (in the example, the first A-sharp in the next bar also has to be notated with a # sign).
If the piece is in a tonality/a key with sharps or flats, i.e. there is a signature at the beginning of the staff, some notes are in default sharp or flat, as indicated in the signature. Then when the natural notes is used, the ╘╕ sign must be notated as other accidental signs. The reset sign is the same as the sign in the signature. For example, in a piece in A major, which has F-sharp, C-sharp and G-sharp in the signature, if the G-natural is used, the ╘╕sign must be notated. After this, to reset to the default G-sharp the # sign is notated.
For the cases when after an accidental there is another accidental, notating the respective accidental sign is enough. However sometimes the natural sign is also notated, as in these cases: a flat note after a sharp note is notated with b╘╕ (or ╘╕b), a sharp note after a flat note is notated with #╘╕ (or ╘╕#), a flat note after a double flat note is notated with b╘╕ (or ╘╕b), a sharp note after a double sharp note with #╘╕ (or ╘╕#) and so on, although these are complicated and rarely met.
In some former notation practices, an accidental sign or a reset sign is only valid for the same notes of the same octave (until the end of the bar/measure) only, which means the accidental sign or the reset sign must be also notated for the notes with the same name on other octaves. Sometimes, also the # or b signs in the signature are also notated on some different octaves, but this is not meaningful because notes on other octaves than these can also appear (notes on auxiliary lines). In some other notation practices, the accidental sign is only valid once for the note it is notated with, which means all accidentals must be written with an accidental sign, otherwise they are natural or default notes, even in the same bar/measure. To indicate a double sharp of a sharp note in the signature or a double flat of a flat note in the signature, in some notation practices, only a # sign (instead of × sign) or a b sign (instead of bb sign) is notated, which may be confusing in reading.