The goal of regression is to forecast a continuous output value. Assume you're attempting to forecast a brand's income based on a variety of input characteristics. A regression model is a function that can theoretically produce any revenue amount based on specified inputs. It may even generate revenue amounts that did not show in your training set.
Other examples of regression can be predicting house prices based on certain features, or predicting weather conditions.
The goal of classification is to figure out whether the class the input belongs to (a discrete integer or a categorical label). Take, for example, dividing sales into Low and High sales and attempting to develop a model that might forecast Low or High sales (binary/two-class classification). Even if the inputs are the same as previously, the outcome will be different. In the case of classification, your model would provide one of two responses: "Low" or "High," and each input would theoretically yield only one of these two outputs.
Few more examples for classification tasks are classifying tumor as benign or malignant, classify income groups into income >50K or <=50K, classifying penguin species into Adelie, Gentoo or Chinstrap.
thus when we have discrete groups we put them under classification and when we have continuous data we put them under regression.