Sie sind auf Seite 1von 4

c# Learning

============

call function Arun


-------------------
string arun;
Console.WriteLine("\nEnter Your good name : ");
arun = Console.ReadLine();
Console.WriteLine(" Welcome {0} to learn C# Knowledge", arun);
Console.ReadLine();
------------------------------------------------------------------------------
Addition of two number
int a, b, c;
Console.Write("Enter the first value : ");
a = Int32.Parse(Console.ReadLine());
Console.Write("Enter the 2nd value : ");
b = Int32.Parse(Console.ReadLine());
c = a + b;
Console.WriteLine("\n\t Addition of {0} and {1} is {2}", a, b, c);
Console.ReadLine();
--------------------------------------------------------------------------------
--
Arithmetic and Assignment operator

int num1, num2;


Console.Write("Enter 1st Number : ");
num1 = Int32.Parse(Console.ReadLine());
Console.Write("Enter 2nd Number : ");
num2 = Int32.Parse(Console.ReadLine());
num1 += num2; // same as num1=num1+num2
Console.WriteLine("Add = {0}", num1);
num1 -= num2; // same as num1=num1-num2
Console.WriteLine("\n\nSubtraction = {0}", num1);
num1 *= num2; // same as num1=num1*num2
Console.WriteLine("\n\nMultiplication={0}", num1);
num1 %= num2; // same as num1=num1%num2
Console.WriteLine("\n\nModulus = {0}", num1);
Console.ReadLine();
--------------------------------------------------------------------------------
-----

Login condition

string name, password;


name = "Arun";
password = "123";
Console.WriteLine("*****************");
Console.Write(" \vUsername : ");
name = Console.ReadLine();
Console.Write(" \nPassword : ");
password = Console.ReadLine();

if (name == "Arun" && password == "123")


{
Console.WriteLine("Login Successful");
}
else
{
Console.WriteLine("Unauthorised access");
}
Console.ReadLine();
--------------------------------------------------------------------------------
------

string Name;
int ROll_no;
int Age;
string section;
string University;

Console.Write("Enter Name of the Student");


Name = Console.ReadLine();
Console.Write("Enter Roll.no : ");
ROll_no = Int32.Parse(Console.ReadLine());
Console.Write("Enter Age");
Age = Int32.Parse(Console.ReadLine());
Console.Write("Enter the Section");
section = Console.ReadLine();
Console.Write("Enter the name of University");
University = Console.ReadLine();
Console.WriteLine("=======================");
Console.WriteLine("\n The Student Informations are : ");

Console.WriteLine("Name : {0}", Name);


Console.WriteLine("Roll.no : {0}", ROll_no);
Console.WriteLine("Age : {0}", Age);
Console.WriteLine("Section : {0}", section);
Console.WriteLine("University : {0}", University);
Console.ReadLine();

------------------------------------
multi Login
string username, userpassword;
label: //Creating label
Console.Write("\n\nEnter your login name:\t");
username = Console.ReadLine();
Console.Write("Enter your password:\t");
userpassword = Console.ReadLine();
try
{
if ((username == "sarath" || username == "arun") && (userpasswor
d == "me" || userpassword == "you"))
{
Console.WriteLine("\nLogin Successful.");
}
else
{
Console.WriteLine("\nUnauthorised Access. Aborting...");
}
Console.Write("\n\nPress Y or y for continue. Press N or n for E
xit:\t");
char ans = Convert.ToChar(Console.ReadLine());
if (ans == 'Y' || ans == 'y')
{
goto label; //goto label
}
else
{
Console.WriteLine("Press Enter for Aborting...");
Console.ReadLine();
return;
}
}
catch { }
-----------------------------------=
sarath condition

int range;
Console.WriteLine("Enter the Aim Point : ");
range = Int32.Parse(Console.ReadLine());
// 50-70 high //70-100 Prefect // 100< aim low

if((range ==0) || (range ==70))


{
Console.WriteLine("Your Aim is High");
}
else if((range==70) || (range ==100))
{
Console.WriteLine("Perfect");
}
else if(range >100)
{
Console.WriteLine("Aim Low");
}
Console.ReadLine();

Das könnte Ihnen auch gefallen