Found 34490 Articles for Programming

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

579 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

766 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

Fraction module in Python

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

5K+ Views

In Python the Fraction module supports rational number arithmetic. Using this module, we can create fractions from integers, floats, decimal and from some other numeric values and strings. There is a concept of Fraction Instance. It is formed by a pair of integers as numerator and denominator. The class fractions.Fractionis used to create a Fraction object. It takes Numerator and Denominator. The default value of the numerator is 0 and denominator is 1. It raises ZeroDivisionError when the denominator is 0. At first we will see how the class can create fractions using Numerator and Denominator. Example code Live ... Read More

First Class functions in Python

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

2K+ Views

In different programming languages, First Class objects are those objects, which can be handled uniformly. First Class objects can be stored as Data Structures, as some parameters of some other functions, as control structures etc. We can say that a function in Python is First Class Function, if it supports all of the properties of a First Class object. What are the properties of First Class Functions? It is an instance of an Object type Functions can be stored as variable Pass First Class Function as argument of some other functions Return Functions from other function Store Functions in ... Read More

C# Program to create Pascal’s Triangle

Chandu yadav
Updated on 26-Jun-2020 14:45:44

4K+ Views

A Pascal’s triangle contains numbers in a triangular form where the edges of the triangle are the number 1 and a number inside the triangle is the sum of the 2 numbers directly above it.A program that demonstrates the creation of the Pascal’s triangle is given as follows.Example Live Demousing System; namespace PascalTriangleDemo {    class Example {       public static void Main() {          int rows = 5, val = 1, blank, i, j;          Console.WriteLine("Pascal's triangle");          for(i = 0; i

Advertisements