Found 34494 Articles for Programming

How to multiply a given number by 2 using Bitwise Operators in C#?

Ankith Reddy
Updated on 27-Jun-2020 06:43:29

4K+ Views

A number can be multiplied by 2 using bitwise operators. This is done by using the left shift operator and shifting the bits left by 1. This results in double the previous number.A program that demonstrates multiplication of a number by 2 using bitwise operators is given as follows.Example Live Demousing System; namespace BitwiseDemo {    class Example {       static void Main(string[] args) {          int num = 25, result;          result = num

Python Program to detect the edges of an image using OpenCV

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

470 Views

In this problem, we will see how Python can detect edges of an image or video file. To achieve this, we need the OpenCV library. The OpenCV library is mainly designed for computer vision. It is open source. Originally it was designed by Intel. This is free to use under open-source BSD license. To use the OpenCV functionality, we need to download them using pip.The OpenCV will download the Numpy module. That will also be needed. sudo pip3 install opencv-python As input, in this case, we have used one video file. We can also use our webcam to ... Read More

How to perform Merge Sort using C#?

Arjun Thakur
Updated on 27-Jun-2020 06:50:48

2K+ Views

Merge Sort is a sorting algorithm that uses the divide and conquer method. It divides the array into two parts and then calls itself for each of these two parts. This process is continued until the array is sorted.A program that demonstrates merge sort in C# is given as follows −Example Live Demousing System; namespace QuickSortDemo {    class Example {       static public void merge(int[] arr, int p, int q, int r) {          int i, j, k;          int n1 = q - p + 1;          int ... Read More

C# program to multiply two matrices

Chandu yadav
Updated on 26-Jun-2020 14:37:01

9K+ Views

The program for matrix multiplication is used to multiply two matrices. This procedure is only possible if the number of columns in the first matrix are equal to the number of rows in the second matrix.A program that demonstrates matrix multiplication in C# is given as follows −Example Live Demousing System; namespace MatrixMultiplicationDemo {    class Example {       static void Main(string[] args) {          int m = 2, n = 3, p = 3, q = 3, i, j;          int[, ] a = {{1, 4, 2}, {2, 5, 1}};     ... Read More

Send mail with attachment from your Gmail account using Python

Samual Sam
Updated on 30-Jul-2019 22:30:23

10K+ Views

In this article, we will see how we can send email with attachments using Python. To send mail, we do not need any external library. There is a module called SMTPlib, which comes with Python. It uses SMTP (Simple Mail Transfer Protocol) to send the mail. It creates SMTP client session objects for mailing. SMTP needs valid source and destination email ids, and port numbers. The port number varies for different sites. As an example, for google the port is 587. At first we need to import the module to send mail. import smtplib Here we are also ... Read More

Class method vs static method in Python

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

19K+ Views

The class method in Python is a method, which is bound to the class but not the object of that class. The static methods are also same but there are some basic differences. For class methods, we need to specify @classmethod decorator, and for static method @staticmethod decorator is used. Syntax for Class Method. class my_class: @classmethod deffunction_name(cls, arguments): #Function Body return value Syntax for Static Method. class my_class: @staticmethod deffunction_name(arguments): ... Read More

C# program to perform Quick sort using Recursion

George John
Updated on 26-Jun-2020 14:41:50

5K+ Views

Quick Sort is a sorting algorithm that uses the divide and conquer method. It takes a pivot element and places it in its correct position. Then the array to the left and right of the pivot element are again sorted using Quick Sort. This is done until the whole array is sorted.A program that demonstrates Quick Sort using Recursion in C# is given as follows −Example Live Demousing System; namespace QuickSortDemo {    class Example {       static public int Partition(int[] arr, int left, int right) {          int pivot;          pivot = ... Read More

How to access elements of an array using pointer notation in C#?

Ankith Reddy
Updated on 26-Jun-2020 14:43:07

573 Views

Usage of pointers in C# require the unsafe modifier. Also array elements can be accessed using pointers using the fixed keyword. This is because the array and the pointer data type are not the same. For example: The data type int[] is not the same as int*.A program that demonstrates accessing array elements using pointers is given as follows.Exampleusing System; namespace PointerDemo {    class Example {       public unsafe static void Main() {          int[] array = {55, 23, 90, 76, 9, 57, 18, 89, 23, 5};          int n = ... Read More

Template matching using OpenCV in Python

Samual Sam
Updated on 30-Jul-2019 22:30:23

762 Views

The Template matching is a technique, by which a patch or template can be matched from an actual image. This is basically a pattern matching mechanism. In Python there is OpenCV module. Using openCV, we can easily find the match. So in this problem, the OpenVC template matching techniques are used. To use the OpenCV functionality, we need to download them using pip. sudo pip3 install opencv-python For template matching task, there is an accuracy factor, this factor is known as threshold. As an example, we can say that we can easily create face recognizing scheme using this ... Read More

Validate IP Address in C#

Arjun Thakur
Updated on 26-Jun-2020 14:43:52

1K+ Views

An IP Address is an Internet Protocol address that is a series of numbers assigned to each device on a computer network. In C#, the class IPAddress class in the namespace System.Net deals with IP addresses.A program that is used to validate an IP address is given as follows −Example Live Demousing System; using System.Net; using System.Net.Sockets; using System.Text.RegularExpressions; namespace IPaddressDemo {    class Example {       public static void Main() {          IPAddress IP;          Console.WriteLine("Enter the IP Address: ");          string ipAddr = Console.ReadLine();         ... Read More

Advertisements