Found 26504 Articles for Server Side Programming

Char.IsControl(String, Int32) Method in C#

AmitDiwan
Updated on 04-Nov-2019 08:06:22

524 Views

The Char.IsControl(String, Int32) method in C# is used to indicate whether the character at the specified position in a specified string is categorized as a control character.Syntaxpublic static bool IsControl (string str, int index);Above, str is a string. The index parameter is the position of the character to evaluate in str.Let us now see an example to implement the Char.IsControl(String, Int32) method −Exampleusing System; using System.Globalization; public class Demo {    public static void Main(){       string val = "hjk9878hj";       Console.WriteLine("String = "+val);       UnicodeCategory unicode = Char.GetUnicodeCategory(val, 4);       Console.WriteLine("The ... Read More

Find the other-end coordinates of diameter in a circler in C++

Arnab Chakraborty
Updated on 04-Nov-2019 08:03:14

96 Views

Suppose we have the center coordinate and one coordinate point on the perimeter of the circle. We have to find the another point on the perimeter. Consider the center points are (p, q), and one given point is (a, b). We have to find the point (x, y). As we know that the center is the middle point of the diameter. So we can write them like −(p, q)=(a+x/2, b+y/2)Or from this the (x, y) can be expressed as −x=2p-a, y=2q-bExample#include using namespace std; int getCylinderPerimeter(int d, int h) {    return (2*d) + (2*h); } int main() {   ... Read More

Find the Number which contain the digit d in C++

Arnab Chakraborty
Updated on 04-Nov-2019 08:01:20

171 Views

Consider we have a digit d, and the upper limit n. we have to find all numbers that contains d in range 0 to n. So if n = 20, and digit is 3, then the numbers will be [3, 13].To solve this problem, we will take every number as string, then if the digit is present in the string, the number will be printed, otherwise ignored.Example#include using namespace std; int getAllNumWithDigit(int n, int d) {    string str = "";    str += to_string(d);    char ch = str[0];    string p = "";    p += ch;    for (int i = 0; i

Find the Next perfect square greater than a given number in C++

Arnab Chakraborty
Updated on 04-Nov-2019 07:55:45

521 Views

Suppose we have a number n. our task is to find next perfect square number of n. So if the number n = 1000, then the next perfect square number is 1024 = 322.To solve this, we have get the square root of the given number n, then take the floor of it, after that display the square of the (floor value + 1)Example#include #include using namespace std; int justGreaterPerfectSq(int n) {    int sq_root = sqrt(n);    return (sq_root + 1)*(sq_root + 1);    } int main() {    int n = 1000;    cout

Find the length of each string element in the Numpy array in C++

Arnab Chakraborty
Updated on 04-Nov-2019 07:52:59

153 Views

Here we will see how to get the length of each string element in the Numpy Array. Numpy is a library for Numeric Python, and it has very powerful array class. Using this we can store data in an array like structure. To get the length we can follow two different approach, these are like below −Exampleimport numpy as np str_arr = np.array(['Hello', 'Computer', 'Mobile', 'Language', 'Programming', 'Python']) print('The array is like: ', str_arr) len_check = np.vectorize(len) len_arr = len_check(str_arr) print('Respective lengts: ', len_arr)OutputThe array is like: ['Hello' 'Computer' 'Mobile' 'Language' 'Programming' 'Python'] Respective lengts: [ 5 8 6 8 ... Read More

Dictionary.ContainsValue() Method in C#

AmitDiwan
Updated on 04-Nov-2019 07:59:08

4K+ Views

The Dictionary.ContainsValue() method in C# is used to check whether the Dictionary contains a specific value or not.Syntaxpublic bool ContainsValue (TValue val);Above, Val is the value to be searched.Let us now see an example to implement the Dictionary.ContainsValue() 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 ... Read More

Find the first, second and third minimum elements in an array in C++

Arnab Chakraborty
Updated on 18-Dec-2019 11:21:51

254 Views

Suppose we have an array of n elements. We have to find the first, second and the third minimum elements in the array. First minimum is the minimum of the array, second min is minimum but larger than the first one, and similarly the third min is minimum but greater than second min.Scan through each element, then check the element, and relate the condition for first, second and third min elements conditions to solve this problem.Example#include using namespace std; int getThreeMins(int arr[], int n) {    int first = INT_MAX, sec = INT_MAX, third = INT_MAX;       for ... Read More

Dictionary.ContainsKey() Method in C#

AmitDiwan
Updated on 04-Nov-2019 07:49:19

2K+ Views

The Dictionary.ContainsKey() method in C# checks whether the Dictionary

Find the final X and Y when they are Altering under given condition in C++

Arnab Chakraborty
Updated on 08-Jul-2020 07:33:12

109 Views

Consider we have the initial values of two positive integers X and Y. Find the final value of X and Y, such that there will be some alteration as mentioned below −step1 − If X = 0 and Y = 0 then terminate the process, otherwise go to step2step2 − If X >= 2Y, then set X = X – 2Y, and go to step1, otherwise go to step3step3 − If Y >= 2X, then set Y = Y – 2X, and go to step1, otherwise end the process.The number X and Y will be in range [0 and 1018] ... Read More

Find sum of factorials in an array in C++

Arnab Chakraborty
Updated on 04-Nov-2019 07:43:09

241 Views

Consider we have an array A, which is sorted. It has all elements appears twice, but one element is present for only one time. We have to find that element. If the array is [1, 1, 3, 3, 4, 4, 5, 6, 6, 7, 7, 9, 9], so the single element is 5.We will use the binary search approach to solve this. All elements before the single element has their first occurrence at index 0, 2, 4, … and first occurrence at index 1, 3, 5, … but after the single element, all occurrences of the first number will be ... Read More

Advertisements