Hi Friends this time I am sharing you a very simple basic programs that generally asked at the time of interview. I used to asked
it some times a very very simple programs ..we know that we can make it out those program but in interview time if you know how to
do that then you can make it out very easyly and make a face that you are thinking about it ;) .. but you know already . and write
it after some moments . ;)
So just take a look before the interview ..!!
All the best friends..!!
Prog1:Retrun Vowel of Not.
Solution:
======
public bool CheckVowel(object sender,KeyEventArgs e)
{
if(e.KeyCode ==Keys.A||e.KeyCode ==Keys.E||e.KeyCode ==Keys.I||e.KeyCode ==Keys.O||e.KeyCode ==Keys.U)
{
return true;
}
else
return false;
}
Prog 2: Even Or Odd
Solution:
======
public string EvenOrOdd( int Num)
{
if(num%2 ==0)
retrun "evenNumber";
else
return "OddNumber"
}
Prog3:PrimeNumber
Soultion:
======
public string PrimeOrNot(int num)
{
int i = 0;
for (i = 3; i < num; i++)
{
if (num % i == 0)
{
Console.WriteLine("{0} is not a prime number", num);
break;
}
}
if (i == num)
{
Console.Writeline("{0} is a prime Number", num);
}
}
Prog4:Fibonacci Series
Solution:
=======
public void FibonacciSeries(int number)
{
int f_0 = 0;
int f_1 = 1;
int sum;
Console.Write("{0} {1} ", f_0, f_1);
for (int i = 2; i < number; i++)
{
sum = f_0 + f_1;
f_0 = f_1;
f_1 = sum;
int value = f_0 + f_1;
Console.Write("{0} ", value);
}
}
Prog5: Factorial
Solution:
=======
public int Factorial(int number)
{
int value = 1;
for (int i = 1; i <= number; i++)
{
value = value * i;
}
return value;
}
Prog:6 Permutation (nPr)
Solution:
======
Refrence Solution 5;
public double Permutation(int n, int r)
{
double nPr = Factorial(n) / Factorial(n - r);
return nPr;
}
Prog:7 Combination(nCr)
Solution:
======
Refrence Solution 5;
public double Combination(int n , int r)
{
double nCr = Factorial(n)/Factorial(r)*(Factorial(n-r);
return nCr;
}
Prog8 : Add two numbers without using the plus operator
Solution:
======
public int Add (int x , int y )
{
return x-(-y);
}
Prog9: Multiply two numbers without usering * operator
Solution:
=======
public int MulWithOutStarOperator( int x ,int y)
{
for(int z= 1 ; z<=y ; z++)
{
int value = value +x;
}
return value;
}
Prog:10 String Reverse
Solution:
=======
public string ReverseString(string str)
{
int strLenght = str.Lenght;
char strArray[] = new char[strLength];
for ( int i = 0 ; i
Prog:11 Return multiple values from a function
Solution:
========
public int Add(int a,int b,out int c)
{
c=a+1;
return a+b;
}
Description :
---------------
when we call the Add method we will get the sum of the a
and b and can also use the value of c
like
int d=0;
int e= Add(2,3,d) ;
then the value of e will be 5 and the value of d will be 3.