except using scanf for a float in the block just before
is the key to your problem. If you do scanf("%f", &var)
, and enter a number terminated with a line feed, scanf will NOT read the line feed. Try entering "123abcd" for your float and you'll see the abcd will get stuffed into major.
Use scanf("%f ", &var)
to skip over any potential whitespace behind your number (note the blank in the format string).
Besides, you shouldn't use gets, as it may cause buffer overflows, but if you're just starting to learn, this probably isn't your main problem right now.