What is the best exercise for speed & accuracy?

I am learning theory basics and have learned how to construct Major scales, but I still don't get how to construct a solo, let's say, in the key of C Major.

For example, C Major is made up of CDEFGAB, am I only allowed to move within these notes? I can't play F# correct? What constitutes a, "good" note and a "bad" note?
you can play the relative majors/minors IE Circle of 5ths/and circle of 4hts
Quote by JacobTheMe
JacobTheEdit: Hell yeah Ruben.

Quote by Jackal58
I met Jesus once. Cocksucker still owes me 20 bucks.
For the most part a "good" note depends on the harmony. So say that you're playing over C major 7th (C E G B), and you sustain an F. F, despite being in the scale of C major might well come off as a "bad" note, as it is an 'avoid note' (A note that is a half-step above the proceeding chord tone, in this case E, as a I major seventh is most commonly constructed from an ionian mode). Modes are a great starting point to start soloing, particularly in modal music, arpeggiated scales do well for soloing over changes.

To me a good note is what you think sounds good, bad note is bad.

These bad or good notes are what incorporates into what particular emotion you're putting into your playing.

As for the scales. Staying in C major will continue to be in the key of C major. If you're not staying in Cmajor, and are using other notes, the scale is now in a different key.

Speed and Accuracy could be worked on by practicing scales up and down the fretboard at your pace.
Most of the important things

in the world have been accomplished

by people who have kept on

trying when there seemed to be no hope at all
Speed should be a secondary concern. The best advice I've always heard is that speed is a byproduct of accuracy. Thus, your focus should be on the most relaxed and accurate way to play something. For an exercise, I would recommend using spider exercises. They are really good for improving finger independence and accuracy. Check the exercise sticky for more info.

For composition, you may use any note. An F# will sound odd over a Cmaj chord, and if you are using only the key of C major (C, D, E, F, G, A, and B), it is technically incorrect. However, depending on the chords underneath the solo, an F# might be appropriate. An F# might also be used to create dissonance that improves a chord resolution.

Let's say you're resolving to a Cmaj triad (which is made up of C, E, and G). You might play a run including the F#, which will sound "off" over a Cmaj triad. In doing so, the dissonance emphasizes the resolution to G. Try that out and see how it sounds.

For more information about modes, check this link:
Be forewarned, however. The post assumes that the reader knows a moderate amount of music theory already and understands the poster's notation.
theory is more like a set of guide lines than a set of rules. to make a good solo you're probably going to have to use notes from more than one key. just make sure they flow well. try to find a couple of notes that bridge the keys. when i say that I mean find a note from both keys that sound good back to back, then you can use that as a way to move from one key to the next.
Just because you're in C major doesn't mean you only have to use C major notes. For example, F# is not in C major. It will sound "bad". This is called dissonance. Call it the opposite of harmony. Use dissonance to your advantage, it will make your harmonies sound even sweeter. You could start a solo off on an F# while a C major chord is being played to make some dissonance, then slowly bend into a G, which is in the C chord being played. The dissonance will slowly turn into a pleasing harmony.
Basic exercise for speed = play everything SLOWLY enough that you can play cleanly and accurately all the time. That way you build your coordination between your picking and fretting hands, and can work on economy of motion - speed is kind of a byproduct that happens as those two things improve.

If you are soloing in C Major, first off you can't just use the relative minor, or other scales, or other modes.

If you are soloing in C Major you can use any of the notes from the C Major scale, and you can generally be confident they will sound pretty good. If you're just starting out I'd stick to those 7 for now, til you get confident.

You can use other notes, but 'outside' notes are harder to make sound good than notes from the scale - which is why I suggest you get used to using the scale, and then start experimenting.

A 'good' note is one that sounds good, a 'bad' note is one that doesn't simple as

Try listening to your chord progression/backing track and singing a 'solo' over it, then try playing that on your guitar.