using System;
class myclass
{
static void Main()
{
int fn = 0;
int sn = 1;
int tn = 1;
Console.WriteLine(fn);
Console.WriteLine(sn);
while (true)
{
tn = fn + sn;
if (tn >= 100)
{
break;
}
Console.WriteLine(tn);
fn = sn;
sn = tn;
}
Console.Read();
}
}
|
C# | ASP.Net | MVC | SQL Server | jQuery | Java Script | LINQ | SSRS| Web Application | Bootstrap | Kendo
Thursday, 16 October 2014
Program to print Fibonacci Numbers below 100 in c#
Reverse a number using C#
using System;
namespace Learn
{
class Program
{
static void
Main(string[] args)
{
Console.WriteLine("Enter a Number");
int numb =
int.Parse(Console.ReadLine());
int reverse = 0;
while (numb > 0)
{
int rem = numb
% 10;
reverse =
(reverse * 10) + rem;
numb = numb /
10;
}
Console.WriteLine("Reverse number={0}", reverse);
Console.ReadLine();
}
}
}
|
Reverse a string in C#.NET
using System;
namespace Learn
{
class Program
{
static void
Main(string[] args)
{
string Str, Revstr
= "";
int Length;
Console.Write("Enter A String : ");
Str =
Console.ReadLine();
Length = Str.Length
- 1;
while (Length >= 0)
{
Revstr = Revstr
+ Str[Length];
Length--;
}
Console.WriteLine("Reverse
String Is {0}", Revstr);
Console.ReadLine();
}
}
}
|
Subscribe to:
Posts (Atom)