Skin cancer represents one of the primary forms of cancer arising from various dermatological disorders. It can be further categorized based on morphological characteristics, coloration, structure, and texture. Given the rising incidence of skin cancer, its significant mortality rates, and the substantial costs associated with medical treatment, the imperative lies in early detection to promptly diagnose symptoms and initiate appropriate interventions. Traditionally, skin cancer diagnosis and detection involve manual screening and visual examination conducted by dermatologists. these techniques are complex, error-prone, and time-consuming. Machine learning algorithms, particularly deep learning approaches, have been applied to analyze images of skin lesions, detect potential cancerous growths, and provide predictions regarding the likelihood of malignancy. In this paper, we have developed an optimized deep convolutional neural network (DCNN) specifically tailored for classifying skin lesions into benign and malignant categories. Thereby, enhancing the precision of disease diagnosis. Our study encompassed the utilization of a dataset comprising 3,297 dermoscopic images. To enhance the model's performance, we applied rigorous data preprocessing techniques and softmax activation algorithms. The suggested approach employs multiple optimizers, including Adam, RMSProp, and SGD, all configured with a learning rate of 0.0001. The outcomes of our experiments reveal that the Adam optimizer outperforms the others in distinguishing benign and malignant skin lesions within the ISIC dataset, boasting an accuracy score of 84%, a loss rate of 32%, a recall rating of 85%, a precision score of 85%, a f1-score of 85%, and a ROC-AUC of 83%.