C++

Make a color image to gray scale image using C++

  #include <opencv2/opencv.hpp> using namespace cv; int main() { // Read the color image Mat colorImage = imread(“input_color_image.jpg”, IMREAD_COLOR); // Convert the color image to grayscale Mat grayImage; cvtColor(colorImage, grayImage, COLOR_BGR2GRAY); // Save the grayscale image imwrite(“output_gray_image.jpg”, grayImage); return 0; }   1 ) In these code we explain about the this line includes the …

Make a color image to gray scale image using C++ Read More »

Write a C++ program to find the last element of an array

Here, we discuss how we find the last element of an array using C++. CODE #include<iostream> using namespace std; int main(){ int arr[]={5,6,7,8,9} int size = sizeof(arr) / sizeof(arr[0]); int lastElement = arr[size – 1]; cout<<“The last element of the array is: “<<lastElement<<endl; return 0; } OUTPUT The last element of the array is: 9 …

Write a C++ program to find the last element of an array Read More »

How to Detect Operating system using C++

In this tutorial, we will learn how to detect operating systems using C++. Detecting operating systems is a common requirement when you develop a cross-platform project that’s why today we learn how to detect the operating system using C++. Detect Operating system using C++ #include <iostream> #if defined(_WIN32) const std::string OS = “Windows”; #elif defined(__APPLE__) …

How to Detect Operating system using C++ Read More »

How to remove null values from an array in C++

In this tutorial, we will learn how to remove null values from an Array in C++. It is important to remove the null value for Memory Optimization,Efficient Data Processing, and Data Integrity purposes. Removing null values from arrays is a common task in C++ programming, especially in data processing and algorithm development Approaches to remove …

How to remove null values from an array in C++ Read More »

Listing files and folders of a specific directory in C++

This tutorial will teach us how files and folders are listed in a specific directory.  And we are going to complete this process using C++ Programming Language. C++ Implementation #include <sys\stat.h> #include <iostream> #include <dirent.h> #include <conio.h> using namespace std; int main () { struct dirent *d; struct stat dst; DIR *dr; string path = …

Listing files and folders of a specific directory in C++ Read More »

Scroll to Top