Melanoma, recognized as the most life-threatening form of skin cancer, poses a significant threat to life expectancy. The timely identification of melanoma plays a crucial role in mitigating the morbidity and mortality associated with skin cancer. Dermoscopic images, acquired through advanced dermoscopic tools, serve as vital resources for the early detection of skin cancer. Hence, there is an urgent need to develop a reliable and accurate Computer-Aided Diagnosis (CAD) system capable of autonomously discerning skin cancer. This study focuses on the meticulous construction of diverse skin cancer classification models, specifically employing various Convolutional Neural Network (CNN) architectures configured across four distinct layer arrangements. Additionally, a transfer learning approach is explored, leveraging robust pre-trained deep CNN models extensively trained on the comprehensive ISIC dermoscopic image dataset, known for its diversity in skin lesions. Utilizing the ISIC dataset as the foundation of our analysis, the CNN model's performance is systematically evaluated with varying numbers of layers-ranging from 15 to 27. Results indicate that the CNN model comprising 15 layers achieves an accuracy of 89.55%, while the model with 27 layers exhibits the highest performance, attaining an accuracy of 90.85%. In the realm of transfer learning, ten baseline CNN models pre-trained on ImageNet are employed. All baseline models demonstrate accuracies surpassing 80%, with SqueezeNet recording the lowest accuracy at 80.89%. In contrast, the ResNet-50 model consistently outperforms other models in transfer learning, achieving an accuracy of 92.98%. These findings underscore the efficacy of the proposed models in melanoma classification and highlight the superior performance of the ResNet-50 model in the context of transfer learning.