Wednesday, August 17, 2011

Arrays in c#


There are two types of arrays :

1)One Dimensional Array
2)Multi or Double Dimensional arrays

Programs for 1d array

1)Simple array program

class abc
{
static void Main()
{
string[] names=new string[5];
for(int i=0;i<5;i++)
{
System.Console.WriteLine("Enter name of People");
names[i]=System.Console.ReadLine();
}
for(int i=0;i<5;i++)
{
System.Console.WriteLine(names[i]);
}
}}


2)Reverse an array

class abc
{
static void Main()
{
int[] a={45,66,43,12,85};
for(int i=0;i {
System.Console.WriteLine(a[i]);
}
System.Array.Reverse(a);
System.Console.WriteLine("reverse is");

for(int i=0;i {
System.Console.WriteLine(a[i]);
}
}
}

Two dimensional arrays

1)Program for Populationa and sector

using System;
class abc
{
static void Main()
{
int[ , ] population = new int [5,2];
for(int i=0;i<5;i++)
{
Console.Write("Enter secttor no. ");
population[i,0]=Convert.ToInt32(Console.ReadLine());

Console.Write("Enter Population ");
population[i,1]=Convert.ToInt32(Console.ReadLine());
}
for(int i=0;i<5;i++)
{
Console.WriteLine("{0} population is {1}",population[i,0],population[i,1]);
}
}
}

2)Transpose of a matrix

class abc
{
static void Main()
{
int[ , ] matrix = new int[4,4];


int[ , ] matrix2 = new int[4,4];

for(int j=0;j<=3;j++)
{
for(int i=0;i<=3;i++)
{
System.Console.Write("Enter Element {0},{1} : ",j,i);
matrix[j,i]=System.Convert.ToInt32(System.Console.ReadLine());
}
}

for(int j=0;j<=3;j++)
{

for(int i=0;i<=3;i++)
{
System.Console.Write(matrix[j,i]);
}
System.Console.WriteLine("");
}

System.Console.WriteLine("its transpose is");

for(int j=0;j<=3;j++)
{
for(int i=0;i<=3;i++)
{
matrix2[i,j]=matrix[j,i];
}
}
for(int j=0;j<=3;j++)
{
for(int i=0;i<=3;i++)
{
matrix[i,j]=matrix2[i,j];
}
}

for(int j=0;j<=3;j++)
{

for(int i=0;i<=3;i++)
{
System.Console.Write(matrix[j,i]);
}
System.Console.WriteLine("");
}
}
}

Properities in C#

Property in C# in a method to access data members..it has get and set accesors.These are basically used to keep the data private.

Program 1)To calculate grade and percentage using properties.

class marks
{
private int phy;
private int che;
private int mth;
private char ch;

public int physics
{
set
{
phy=value;
}
get
{
return(phy);
}
}
public int chemistry
{
set
{
che=value;
}
get
{
return(che);
}
}
public int math
{
set
{
mth=value;
}
get
{
return(mth);
}
}
public int total
{
get
{
int total=phy+che+mth;
return(total);
}
}
public float percentage
{
get
{
float percent=(total/3);
return(percent);
}
}
public char grade
{
get
{
int p=(total/3);
if(p>70)
{
ch='A';
}
else
{
ch='B';
}
return(ch);
}
}
}

class abc
{
static void Main()
{
marks p1 = new marks();
p1.chemistry=87;
p1.math=79;
p1.physics=90;

System.Console.WriteLine("Total is {0}",p1.total);
System.Console.WriteLine("Percentage is {0} %",p1.percentage);
System.Console.WriteLine("Grade is {0}",p1.grade);

}
}

Functoins in C#

We wil try with some Basic use of Functions in Console using c#

class abc
{
static void Main()
{
MyDetails("ashir","tangori","b.tech");
string a=System.Console.ReadLine();
string b=System.Console.ReadLine();
string c=System.Console.ReadLine();
MyDetails(a,b,c);
}

static void MyDetails(string nm,string clge,string dgre)
{
System.Console.WriteLine("the name is {0}",nm);
System.Console.WriteLine("college is {0}",clge);
System.Console.WriteLine("degree is {0}",dgre);
}
}

2)Simple addition using functions

class abc
{
static void Main()
{
int x=Sum(7,8);
System.Console.WriteLine("the sum is {0}",x);
}
static int Sum(int a,int b)
{
int y=a+b;
return(y);
}
}

3) Program to check discount using functions

class abc
{
static void Main()
{
int a;
float b;
System.Console.WriteLine("enter quantity");
a=System.Convert.ToInt32(System.Console.ReadLine());
System.Console.WriteLine("Enter price");
b=System.Convert.ToSingle(System.Console.ReadLine());
float c=DiscountedAmount(a,b);
System.Console.WriteLine("The net Price is {0}",c);
}
static int DiscountedAmount(int quan,float price)
{
float total=quan*price;
if(total<10000)
{
float dis=total*5/100;
float net=total-dis;
int a=System.Convert.ToInt32(net);
return(a);
}
else if(total>10000 && total<15000)
{
float dis=total*10/100;
float net=total-dis;
int a=System.Convert.ToInt32(net);
return(a);
}
else if(total>15000 && total<20000)
{
float dis=total*15/100;
float net=total-dis;
int a=System.Convert.ToInt32(net);
return(a);
}
else
{
float dis=total*20/100;
float net=total-dis;
int a=System.Convert.ToInt32(net);
return(a);
}
}
}



Learn Asp.net

Here are my posts to help u learn Asp.Net...
We will start with some basic programs.......

Tuesday, August 16, 2011

Boom Boom Afridi - A Living Legend




Sahibzada Mohammad Shahid Khan Afridi (Urdu: صاحبزادہ محمد شاہد خان آفریدی) (born 1 March 1980 in Khyber Agency of the Federally Administered Tribal Areas, Pakistan[2]), popularly known as Shahid Afridi (Pashto: شاهد ‏افریدی), is a Pakistani cricketer. Between 1996 and 2011, Afridi played 27 Tests, 325 One Day Internationals, and 43 Twenty20 Internationals (T20Is) for the Pakistani national team. He made his ODI debut on 2 October 1996 against Kenya and his Test debut on 22 October 1998 against Australia.
He is known for his aggressive batting style, and holds the record for the fastest ODI century which he made in his first international innings, as well as scoring 32 runs in a single over, the second highest scoring over ever in an ODI.[3] He also holds the distinction of having hit the most number of sixes in the history of ODI cricket.[4] Afridi considers himself a better bowler than batsman, and has taken 48 Test wickets and over 300 in ODIs. Currently Afridi is the leading wicket taker in the Twenty20 format taking 53 wickets from 43 matches.
In June 2009, Afridi took over the Twenty20 captaincy from Younus Khan, and was later appointed ODI captain for the 2010 Asia Cup. In his first match as ODI captain against Sri Lanka he scored a century however Pakistan still lost by 16 runs. He then also took over the Test captaincy but resigned after one match in charge citing lack of form and ability to play Test cricket; at the same time he announced his retirement from Tests. He retained the captaincy in limited-overs form of the game and led the team in the 2011 World Cup. In May 2011, having led Pakistan in 34 ODIs Afridi was replaced as captain. Later that month he announced his conditional retirement from international cricket in protest against his treatment by the Pakistan Cricket Board (PCB).
ull Name : Sahibzada Mohammad Shahid Khan Afridi

Born : March 1, 1980, Khyber Agency

Major Teams : Karachi, Habib Bank Limited, Leicestershire, ICC World XI, Griqualand West, South Australia, Asia XI, Deccan Chargers, Pakistan

Batting Style : Right Hand Bat

Bowling Style : Leg Break and Googly

Test Debut : Pakistan Vs Australia, 3rd Test at National Stadium, Karachi, 1998/99

ODI Debut : Pakistan Vs Kenya at Nairobi (AK), KCA Centenary Tournament, 1996/97



Monday, August 15, 2011

Secret hacking techniques of facebook by Ashir

If u wanna hack someones profile....its easy ...all u need is some basic information about the person u wanna hack....
Hacking is a 2 layer process . In order to hack some1s facebook , u will need to find out his email address. First we will hack the Email address and then the facebook.
1)Click on forgot password
2)Enter the captcha.
3)Then click on answer security questions.
4)If u know the person u will know the answer as well becoz security questions are very basic.
5)After this Enter the new pass word .
6)Now goto Facebook and click on forget ur password.
7)A link will be sent to ur Hacked inbox
8)Click on the Link and facebook is hacked ..

It is a very basic trick n it works....believe me...its easier then it looks..
Do post comments if it works for u..
More hacking tips comming up...Bye for now

My first interview at T.C.S

I have been nervous these dayz as Tcs is comming to our college..
the competition is tough but i thinng i stand a good chance...bt i really need to work hard...ny way these apti papers are taking a toll on me...there r more tha hundreds of them
U can check them out at
http://freshersworld.com/blogs/post/10/08/30/TCS-Complete-Placement-Process-With-Questions-Of-Aptitude,-Technical,-MR-and-HR-
just go on the link and get answer to all ur quesries about tcs...
i wish all of u best of luck.......