Your Ad Here
Showing posts with label Variables. Show all posts
Showing posts with label Variables. Show all posts

Saturday, May 24, 2008

Division Of Two Numbers

/*** C# program to divide two numbers **/

using System;

namespace Program1
{
class except
{
static void Main(string[] args)
{
double a,b,ans;

Console.WriteLine("Enter A Number");
a = Convert.ToDouble(Console.ReadLine());

Console.WriteLine("Enter Another Number");
b = Convert.ToDouble(Console.ReadLine());

ans = a / b;

Console.WriteLine("Answer : " + ans);
}
}
}

Finding Simple Interest

using System;
namespace Interest
{
class Program
{
static void Main(string[] args)
{
int year;
double princ_amt,rate, interest, total_amt;
Console.Write("Enter The Principle Amount : ");
princ_amt = Convert.ToDouble(Console.ReadLine());

Console.Write("Enter The Term : ");
year = Convert.ToInt16(Console.ReadLine());

Console.Write("Enter The Rate Of interest : ");
rate = Convert.ToDouble(Console.ReadLine());

interest = princ_amt * year * rate / 100;
total_amt = princ_amt + interest;

Console.WriteLine("\n----------------------------------------");
Console.WriteLine("Interest : {0} Total Amount : {1}", interest, total_amt);
Console.WriteLine("----------------------------------------");

}
}
}

Friday, May 23, 2008

First Program

using System;

namespace MyFirstPrograms
{
class Program
{
static void Main(string[] args)
{
string name;
Console.Write("What is your name: ");
name = System.Console.ReadLine();

Console.WriteLine("Welcome "+name+" to Your First C# Program!");
}
}
}