Question

In: Computer Science

Write a method in c# to find the summation of which two neighboring digits is equal...

Write a method in c# to find the summation of which two neighboring digits is equal to 8

Ex if N =0176623509808

Output is: 17 ,62 ,35 ,80 , 08

Solutions

Expert Solution

class HelloWorld {
static void Main() {
    string N = "0176623509808";
    neighboringDigits(N);
}
public static void neighboringDigits(string N){
      int i;
      int length = N.Length;
      Console.Write("Output is: ");
      for(i=0;i<length-1;i++)
      {
          if((int)N[i]-48+(int)N[i+1]-48==8){
              Console.Write(N[i]+""+(N[i+1])+" ");
          }
      }
}

}

Screenshot of the program with output :


NOTE: If you want to change something , please let me know through comments; I will surely revert back to you.

Please give a up vote .....
Thank you.......


Related Solutions

5. Write a C++ statement or statements that will:       Print the first two digits and the  last...
5. Write a C++ statement or statements that will:       Print the first two digits and the  last two digits of any 4 digit number stored in an integer variable n.         For example, given int n = 5623, print 56    23. 6. Write  C++ statements that will align the following three lines as printed in two 20 character columns. Name                                                 Years President Abraham Lincoln                                 1860-1865 Thomas Jefferson                               1801-1809 7.  Write a C++ statement or statements that will Output if a string has a length greater than 10, equal...
Given n. Write a program in PYTHON to Generate all numbers with number of digits equal...
Given n. Write a program in PYTHON to Generate all numbers with number of digits equal to n, such that the digit to the right is greater than the left digit (ai+1 > ai). E.g. if n=3 (123,124,125,……129,234,…..789)
Find MIN. Write a C# console app consisting of class MIN with the method CalculateMin() and...
Find MIN. Write a C# console app consisting of class MIN with the method CalculateMin() and the driver class. Print the MIN and MIN's location. Don't count numbers outside the range [0, 100].
Let a, b, c the last three digits of your QUID. Find the dimension of the...
Let a, b, c the last three digits of your QUID. Find the dimension of the rectangular box of maximum volume that can be inscribed in the ellipsoid (x/a)^2+(y/b)^2+(z/c)^2=1 a=4, b=8, c=9
In Haskell Write a function equal that returns whether two sets are equal. equal :: Set...
In Haskell Write a function equal that returns whether two sets are equal. equal :: Set -> Set -> Bool
a) Write C code initialize an array of ints to the last four digits of your...
a) Write C code initialize an array of ints to the last four digits of your phone number. Use a loop to add the digits. Calculate and display the average of the digits. b) Write C code using a struct to hold student information: integer id integer number of hours taken integer number of hours passed double gpa
**C++** Output each floating-point value with two digits after the decimal point, which can be achieved...
**C++** Output each floating-point value with two digits after the decimal point, which can be achieved by executing cout << fixed << setprecision(2); once before all other cout statements. (1) Prompt the user to input a wall's height and width. Calculate and output the wall's area. (2 pts) Note: This zyLab outputs a newline after each user-input prompt. For convenience in the examples below, the user's input value is shown on the next line, but such values don't actually appear...
Determine a two digit number whose value is equal to eight times the sum of its digits and when 45 is subracted from the number, the digits are reversed?
Determine a two digit number whose value is equal to eight times the sum of its digits and when 45 is subracted from the number, the digits are reversed?
Write a C++ function which will search for TWO elements. The two elements must be right...
Write a C++ function which will search for TWO elements. The two elements must be right next to each other, contiguously. The prototype of the function should be: bool search_adjacent_elements(int const *x, size_t n, int target1, target2); It will return true if target1 and target2 exist in the array x somewhere, with target1 immediately to the left of target2. For example: int x[] = { 3, 5, 10, 14, 19, 25, 45, 60 }; cout << search_adjacent_elements(x, sizeof x /...
In a two digit number the sum of the digits is 9. Also, when 27 is subtracted from the number the digits are reversed. Find the number?
In a two digit number the sum of the digits is 9. Also, when 27 is subtracted from the number the digits are reversed. Find the number?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT