// This program tells the user the values of the integers that are
// one more and one less that the entered integer
using System;
public class DebugTwo4
{
public static void Main(string[] argus)
{
string entry;
int enteredInteger;
int more, less;
Console.Write("Enter an integer ");
entry = Console.ReadLine();
Console.WriteLine("You entered {0}", entry);
enteredInteger = Convert.ToInt32(entry);
more = ++enteredInteger;
less = enteredInteger--;
Console.WriteLine("One more than {0} is {1} and one less than {0} is {2}", entry, more, less);
Console.ReadKey();
}
}
/*10 is input then output is "One more than 10 is 11 and one less than 10 is 11" what should be done to get the output "One more than 10 is 11 and one less than 10 is 9. Any one knows please help me */
Loading

Pravin MoreRank #1,419 · 1.2K reputationPosted Nov 24, 2011, 6:59 PM EST
hi Maha, use below code...it will work
using System;
public class DebugTwo4
{
public static void Main(string[] argus)
{
string entry;
int enteredInteger;
int more, less;
Console.Write("Enter an integer ");
entry = Console.ReadLine();
Console.WriteLine("You entered {0}", entry);
enteredInteger = Convert.ToInt32(entry);
int orignalnumber=enteredInteger ;
more = ++enteredInteger;
less = orignalnumber--;
Console.WriteLine("One more than {0} is {1} and one less than {0} is {2}", entry, more, less);
Console.ReadKey();
}
}
Thanks,
Pravin.
Karthik AgarwalRank #2,270 · 620 reputationPosted Nov 24, 2011, 7:59 PM EST
using System;
public class DebugTwo4
{
public static void Main(string[] argus)
{
while(true)
{
string entry;
Console.Write("Enter an integer ");
entry = Console.ReadLine();
Console.WriteLine("You entered {0}", entry);
Console.WriteLine("One more than {0} is {1} and one less than {0} is {2}", entry, Convert.ToInt32(entry) + 1, Convert.ToInt32(entry) - 1);
Console.ReadKey();
}
}
}
VulpesRank #55 · 29.2K reputationPosted Nov 25, 2011, 12:00 AM EST
less = enteredInteger--;
with
less = enteredInteger - 2;
Posted Nov 25, 2011, 2:27 AM EST