Karthikeya Boyini has Published 2383 Articles

String slicing in Python to rotate a string

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 16:09:07

4K+ Views

A string is given, our task is to slicing the string into two way. One is clockwise and another anticlockwise.1. Left (Or anticlockwise) rotate the given string by d elements (where d pythonprogram Left Rotation: thonprogrampy Right Rotation: ampythonprogr

Python program to create 3D list.

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 16:03:40

2K+ Views

3D list means 3D array. In this program we create 3D array with integer elements.ExampleInput: 3× 3 × 2 [[1, 1, 1], [2, 2, 2], [3, 3, 3]], [[4, 4, 4], [5, 5, 5], [6, 6, 6]]AlgorithmStep 1: given the order of 3D list. Step 2: using for loop we ... Read More

Python program to check if both halves of the string have same set of characters.

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 16:01:38

183 Views

Given a string, our task is to check if both halves of the string have the same set of characters or not. To solve this problem we first split the string from the middle, so we get two halves, now we check each halves having the same set of characters ... Read More

How do we use a break statement in while loop in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 15:08:57

170 Views

The break statement terminates the loop and transfers execution to the statement immediately following the loop.When the break statement is encountered inside a loop, the loop is immediately terminated and program control resumes at the next statement following the loop.Let us see an example to learn how to work with ... Read More

Extracting MAC address using C#

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 15:06:50

3K+ Views

A MAC address of a device is a media access control address. It is a unique identifier assigned to a network.The MAC address technology is used by many technologies such as Ethernet, Bluetooth, Fibre Channel, etc.Here, we will use the following method to check for all the network interfaces on ... Read More

How do you sort an array in C# in descending order?

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 14:46:40

4K+ Views

The following is the unsorted array.int[] list = {98, 23, 97, 36, 77};Now first use the Sort() method to sort the array.Array.Reverse(list);Use the Reverse() method that would eventually give you a sorted array in descending order.Array.Reverse(list);You can try to run the following code to to sort an array in descending ... Read More

How do we use multi-dimensional arrays in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 14:45:08

131 Views

C# allows multidimensional arrays. Multi-dimensional arrays are also called rectangular array. Declare a 2-dimensional array of strings as.string [, ] names;A 2-dimensional array can be thought of as a table, which has x number of rows and y number of columns.Multidimensional arrays may be initialized by specifying bracketed values for ... Read More

How do I sort a two-dimensional array in C#

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 14:41:25

2K+ Views

To sort a two-dimensional array in C#, in a nested for loop, add another for loop to check the following condition.Examplefor (int k = 0; k < j; k++) {    if (arr[i, k] > arr[i, k + 1]) {       int myTemp = arr[i, k];     ... Read More

How do you use ‘foreach’ statement for accessing array elements in C#

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 14:39:01

107 Views

To access Array elements in a foreach statement, use the numeric index.Let’s say the following is our code.Example Live Demousing System; namespace ArrayApplication {    class MyArray {       static void Main(string[] args) {          int [] n = new int[10]; /* n is an array ... Read More

How do we pass parameters by value in a C# method?

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 14:32:38

104 Views

This is the default mechanism for passing parameters to a method. In this mechanism, when a method is called, a new storage location is created for each value parameter.The values of the actual parameters are copied into them. Hence, the changes made to the parameter inside the method have no ... Read More

Advertisements