In: Computer Science
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
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.......