Found 26504 Articles for Server Side Programming

Math.DivRem() Method in C#

AmitDiwan
Updated on 04-Nov-2019 10:03:47

2K+ Views

The Math.DivRem() method in C# is used to divide and calculate the quotient of two numbers and also returns the remainder in an output parameter.Syntaxpublic static int DivRem (int dividend, int divisor, out int remainder); public static long DivRem (long dividend, long divisor, long remainder);Let us now see an example to implement Math.DivRem() method −Exampleusing System; public class Demo {    public static void Main(){       int dividend = 30;       int divisor = 7;       int remainder;       int quotient = Math.DivRem(dividend, divisor, out remainder);       Console.WriteLine("Quotient = "+quotient); ... Read More

Char.IsWhiteSpace() Method in C#

AmitDiwan
Updated on 04-Nov-2019 09:59:10

476 Views

The Char.IsWhiteSpace() method in C# is used to indicate whether the specified Unicode character is white space.Syntaxpublic static bool IsWhiteSpace (char ch);Above, the parameter ch is the Unicode character to evaluate.Let us now see an example to implement the Char.IsWhiteSpace() method −Exampleusing System; public class Demo {    public static void Main(){       bool res;       char val = ' ';       Console.WriteLine("Value = "+val);       res = Char.IsWhiteSpace(val);       Console.WriteLine("Is the value whitespace? = "+res);    } }OutputThis will produce the following output −Value = Is the value whitespace? ... Read More

Dictionary.Clear Method in C#

AmitDiwan
Updated on 04-Nov-2019 09:57:21

2K+ Views

The Dictionary.Clear() method in C# removes all key/value pairs from the Dictionary.Syntaxpublic void Clear();Let us now see an example to implement the Dictionary.Clear() method −Exampleusing System; using System.Collections.Generic; public class Demo {    public static void Main(){       Dictionary dict =       new Dictionary();       dict.Add("One", "John");       dict.Add("Two", "Tom");       dict.Add("Three", "Jacob");       dict.Add("Four", "Kevin");       dict.Add("Five", "Nathan");       Console.WriteLine("Count of elements = "+dict.Count);       Console.WriteLine("Key/value pairs...");       foreach(KeyValuePair res in dict){          Console.WriteLine("Key = {0}, ... Read More

Find the product of last N nodes of the given Linked List in C++

Arnab Chakraborty
Updated on 04-Nov-2019 09:59:11

155 Views

Consider we have few elements in a linked list. We have to find the multiplication result of last n number of elements. The value of n is also given. So if the list is like [5, 7, 3, 5, 6, 9], and n = 3, then result will be 5 * 6 * 9 = 270.The process is straight forward. We simply read the current element starting from left side, then add the elements into stack. After filling up the stack, remove n elements and multiply them with the prod. (initially prod is 1), when n number of elements are ... Read More

CharEnumerator.Dispose() Method in C#

AmitDiwan
Updated on 04-Nov-2019 09:53:38

126 Views

The CharEnumerator.Dispose() method in C# is used to release all resources used by the current instance of the CharEnumerator class.Syntaxpublic void Dispose ();Let us now see an example to implement the CharEnumerator.Dispose() method −Exampleusing System; public class Demo {    public static void Main(){       string strNum = "356";       CharEnumerator ch = strNum.GetEnumerator();       while (ch.MoveNext())          Console.Write(ch.Current + " ");       // disposed       ch.Dispose();       // this will show an error since we disposed the object above       // Console.WriteLine(ch.Current);    } }OutputThis will produce the following output −3 5 6

CharEnumerator.Clone() Method in C#

AmitDiwan
Updated on 04-Nov-2019 09:51:58

105 Views

The CharEnumerator.Clone() method in C# is used to create a copy of the current CharEnumerator object.Syntaxpublic object Clone();Let us now see an example to implement the CharEnumerator.Clone() method −Exampleusing System; public class Demo {    public static void Main(){       string strNum = "356";       CharEnumerator ch = strNum.GetEnumerator();       while (ch.MoveNext()){          Console.Write(ch.Current + " ");          CharEnumerator enumClone = (CharEnumerator)ch.Clone();          while (enumClone.MoveNext())             Console.Write(enumClone.Current + " ");          Console.WriteLine();       }    } }OutputThis will produce the following output −3 5 6 5 6 6

Char.IsUpper() Method in C#

AmitDiwan
Updated on 04-Nov-2019 08:14:09

2K+ Views

The Char.IsUpper() method in C# indicates whether the specified Unicode character is categorized as an uppercase letter.Syntaxpublic static bool IsUpper (char ch);Above, the parameter ch is the Unicode character to evaluate.Let us now see an example to implement the Char.IsUpper() method −Exampleusing System; public class Demo {    public static void Main(){       bool res;       char val = 'H';       Console.WriteLine("Value = "+val);       res = Char.IsUpper(val);       Console.WriteLine("Is the value an uppercae letter? = "+res);    } }OutputThis will produce the following output −Value = H Is the ... Read More

Find the product of first k nodes of the given Linked List in C++

Arnab Chakraborty
Updated on 04-Nov-2019 08:17:25

108 Views

Consider we have few elements in a linked list. We have to find the multiplication result of first k number of elements. The value of k is also given. So if the list is like [5, 7, 3, 5, 6, 9], and k = 3, then result will be 5 * 7 * 3 = 105.The processes is straight forward. We simply read the current element starting from left side, then multiply it with the prod. (initially prod is 1), when k number of elements are traversed, then stop.Example#include #include using namespace std;    class Node{       public: ... Read More

Char.IsSymbol() Method in C#

AmitDiwan
Updated on 04-Nov-2019 08:10:17

547 Views

The Char.IsSymbol() method in C# is indicating whether the character at the specified position in a specified string is categorized as a symbol character.Syntaxpublic static bool IsSymbol (string str, int index);Above, str is a string, whereas the position of the character to evaluate in str.Let us now see an example to implement the Char.IsSymbol() method −Exampleusing System; public class Demo {    public static void Main(){       bool res;       char val = 'P';       Console.WriteLine("Value = "+val);       res = Char.IsSymbol(val);       Console.WriteLine("Is the value a symbol? = "+res); ... Read More

Find the perimeter of a cylinder in C++

Arnab Chakraborty
Updated on 04-Nov-2019 08:07:19

178 Views

Suppose we have the diameter and the height of the cylinder, we have to find the perimeter of the cylinder. As the perimeter is the outline of two dimensional object, then we cannot find the perimeter of one three dimensional object directly. We can make a cross section of the cylinder, and convert it as rectangle, then find the perimeter. The two sides of the rectangular cross section are the diameter, and the height. So perimeter is −p=(2*d)+(2*h)Example#include using namespace std; int getCylinderPerimeter(int d, int h) {    return (2*d) + (2*h); } int main() {    int diameter = ... Read More

Advertisements