By Think Positive, Get Positive on 3:45:00 PM
Filed Under:
SWITCH statement
The switch expression must be of an integers, such as char, byte, short, ushort, int or any type of string. Thus the floating point expressiond are not allowed. The case constants must be literals of a type compatible with the expression. Two case constants in the came switch cannot have identical values. The default statement is executed if no case constants matches the expression. The default statement is optional..
Program Demonstrates the switch statement
using system;
class demoswitch
{
public static void Main()
{ int i;
for(i=0; i<6;i++)
switch(i)
{
case 0:
Console.WriteLine("i is zero");
break;
Case 1:
Console.WriteLine("i is one");
break;
Case 2:
Console. WriteLine("i is two");
break;
case 3:
Console.WriteLine("i is three");
break;
case 4:
Console.WriteLine("i is four");
break;
default:
Console.WriteLine("i is five or than more than five");
break;
}
}
}
class="para">output: i is zero
i is one
i is two
i is three
i is four
i is five or more than five
By Think Positive, Get Positive on 5:03:00 PM
Filed Under: Actress wallpapers, Aishwarya, Asin, Charmy, deepika padukone, Genelia, Katrina kaif wallpapers, priyanka chopra, shreya saran
Bool Type:
- Bool is a data type which is to represent the true or false value in C#.
- The Bool type variables or expressions will be true or false.
- Unlike other programming Languauges, there is no conversion between the bool and integers in C#.
Program using bool type
using system;
class exbool
{
public static void Main()
{
bool b;
b= false;
Console.WriteLine("b is"+ false);
b = true;
Console.WriteLine("b is "+ true);
if(b)
{
Console.WriteLine("It is executed");
}
b= false;
if(b)
{
Console.WriteLine("It is not executed")
}
Console.WriteLine("100>99 is"+(100>99))
}
}
Output:
b is false
b is true
It is executed
100>99 is true
By Think Positive, Get Positive on 11:00:00 AM
Filed Under: data types-decimal, decimal type, to compute future value and discount
DECIMAL TYPE
Decimal is the data type utilizes 128 bits which represents within the range 1E-28 to 7.9E+28. It can accurately represents upto 28 decimal places.
Program using Decimal type to compute a discount
using system;
Class discounts
{
public static void Main()
{
decimal price;
decimal discount;
decimal disprice;
price = 16.0;
discount = 0.10
disprice = price - (price*discount);
Console.WriteLine("The Discounted Price : $"+ disprice);
}
}
output:
The Discounted Price:$ 14.4
------------------------------------------------------------------------------------------------
Program using Decimal to compute a future value
using system;
class futurevalue
{
public static void Main()
{
decimal amount;
decimal rateofreturn;
int i, years;
amount = 1000.0;
rateofreturn = 0.07;
years = 10;
Console.WriteLine( "Original Investment:$"+amount);
Console.WriteLine("Rate of Retun:$"+ rateofreturn);
Console.WriteLine("Over"+Years+"Years");
for(i=0;i<=years;i++) { amount = amount+(amount*rateofreturn); Console.WriteLine("The Future Value:$"+amount); } } } Output:
Original Investment : $1000
Rate of return : $0.07
Over 10 Years
The Future Value : $ 1967.15135728956532249000
-----------------------------------------------------------------------------------------------
goto BOOL
By Think Positive, Get Positive on 4:16:00 PM
Filed Under: Area of circle, Double, math.cos, math.sin, math.sqrt, math.tan, Program using double
Double:
Double is one of the floating point type which represents the double precision numbers. Double is 64 bits wide and has an approximate range of 5E-324 to 1.7E + 308. Many of the math function in C# class library uses Double.
Program to find the radius of Circle using the math function math.sqrt
using system;
class circle
{
public static void Main()
{
Double area;
Double radius;
area = 10.0;
radius = math.sqrt(area/3.14);
Console.WriteLine("The radius of Circle:" + radius);
}
}
Output:
The radius of Circle: 1.78412203012729
Program using math.sin, math.cos, math.tan
using system;
class trignometry
{
public static void Main()
{
Double theta;
for(theta=0.1; theta<=1.0; theta=theta+0.1) { Console.WriteLine("sine of"+theta+"is"+ math.sin(theta)); Console.WriteLine("cosine of"+theta+"is"+math.cos(theta)); Console.WriteLine("tangent of" +theta+"is"+math.tan(theta)); } } } Output:
Sine of 0.1 is 0.0998334166468282
Cosine of 0.1 is 0.995004165278026
Tangent of 0.1 is 0.100334672085451
Sine of 0.2 is 0.198669330795061
Cosine of 0.2 is 0.980066577841242
Tangent of 0.2 is 0.202710035508673
Sine of 0.3 is 0.29552020666134
Cosine of 0.3 is 0.955336489125606
Tangent of 0.3 is 0.309336249609623
__________________________________________________________________________________________
goto decimal
By Think Positive, Get Positive on 3:11:00 PM
Filed Under: Integers, program using byte and for loop, program using Long, types of integers
Integers:
- C# defines nine integer types and they are char, byte, sbyte, short, ushort, int, uint, long and ulong.
- The bit width and ranges of integers are shown below
- byte ------------------------- 8 -------------------------0 to 255
- sbyte------------------------- 8 -------------------- -128 to 127
- short -------------------------16---------------- -32768 to 32767
- ushort----------------------- 16--------------------------- 0 to 65535
- int ----------------------------32---------- -2147483648 to 2147483647
- uint --------------------------32 --------------------------- 0 to 4294965295
- long-------------------------- 64-------- −9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
- ulong ------------------------64 -----------------------------0 to 18,446,744,073,709,551,615
using system;
class inch
{
public static void Main()
{
long mile;
long inch;
mile = 93000000;
inch = mile*5280*12;
Console.WriteLine("The distance to the Sun:"+inch+"inches");
}
}
Output:
The distance to the Sun: 5892480000000 inches
Program using byte to control the for loop that produces the summation of the number 100
using system;
class using_byte
{
public static void Main()
{
byte x;
int y;
y=0;
for(x=1;x<+100;x++)
y=y+x;
Console.WriteLine("The sum of 100 is "+y);
}
}
output:
The sum of 100 is 5050
goto Double
Carmania
By Think Positive, Get Positive on 12:47:00 PM
Filed Under: audi wall wallpaper, benz wallpaper, BMW wallpapers, car wallpapers, ferari wallpaper, Lambhorghini, Lotus elise wallpapers, silver car wallpapers, subaru impreza wallpaper, volvo s70 wallpapers
Wallpapers of Cars
Lamborghini
Silver Car
Blue Audi
Audi
Back view of Audi
Black car
Side view of Audi
Audi Le Mans
Lotus Elise
Audi
Audi
B M W
Subaru Impreza
Mercedes Benz
Silver B M W
Audi Silver
Orange Audi
volvo c70
Subaru Wrx Zti
Audi Wings
Silver Car
Lotus 340r
Audi Gold
Ferrari F40
volvo s70
Ferrari Red