frequently asking logical program in interviews for dotnet fresher
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication84
{
class Program
{
static void Main(string[] args)
{
int n, rev = 0, rem;
Console.WriteLine("enter the no:");
n = int.Parse(Console.ReadLine());
while (n != 0)
{
rem = n % 10;
rev = (rev * 10) + rem;
n = n / 10;
}
Console.WriteLine("the reverse no is :{0}", rev);
Console.ReadLine();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication84
{
class Program
{
static void Main(string[] args)
{
int n, rev = 0, rem;
Console.WriteLine("enter the no:");
n = int.Parse(Console.ReadLine());
while (n != 0)
{
rem = n % 10;
rev = (rev * 10) + rem;
n = n / 10;
}
Console.WriteLine("the reverse no is :{0}", rev);
Console.ReadLine();
}
}
}
No comments:
Post a Comment