Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Few Programs that would help in interviews
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { //Few Programs that would help in interviews Console.WriteLine("Hello, Guys!"); SwapTwoNumber(10,20); FibonacciSeries(10); StarPattern1(8); StarPattern2(8); StarPattern3(6, 7); var str = StringReversal("RAMA"); } public static void SwapTwoNumber(int a, int b) { Console.WriteLine("Swap Two Numbers a={0}, b={1}",a,b); a = a+b; b = a-b; a = a-b; Console.WriteLine("After swapping a={0}, b={1}",a,b); } public static void FibonacciSeries(int count) { int a1=0; int a2=1; int a3=0; Console.WriteLine("Fibonacci Series"); for(int i=0; i<=count ; i++) { a3=a1+a2; Console.WriteLine(a3); a1=a2; a2=a3; } } public static string StringReversal(string a) { Console.WriteLine("Reverse a String:{0}", a); char[] actual_str = a.ToCharArray(); char[] reversed_str = new char[actual_str.Length]; int i= 0; for (int j = actual_str.Length - 1; i < actual_str.Length; j--) { reversed_str[i] = actual_str[j]; i++; } Console.WriteLine("Reversed String = {0}",new string(reversed_str)); return new string(reversed_str); } public static void StarPattern1(int x) { Console.WriteLine("PATTERN 1"); for(int rows =1; rows<=x; ++rows) { for(int col=1; col<=rows; ++col) { Console.Write("*"); } Console.WriteLine(); } } public static void StarPattern2(int y) { Console.WriteLine("PATTERN 2"); for(int rows=y; rows>=1 ; --rows) { for(int col=1; col<=rows; ++col) { Console.Write("*"); } Console.WriteLine(); } } public static void StarPattern3(int x, int y) { //Combining two logics of Pattern 1 and Pattern 2 Console.WriteLine("PATTERN 3"); for(int rows =1; rows<=x; ++rows) { for(int col=1; col<=rows; ++col) { Console.Write("*"); } Console.WriteLine(); } for(int rows=y; rows>=1 ; --rows) { for(int col=1; col<=rows; ++col) { Console.Write("*"); } Console.WriteLine(); } } } }
run
|
edit
|
history
|
help
0
Tree Node Sample
min tree
Fórum ➡ Calculate the Sum of Values in List of KeyValuePair<> objects ♦
DI
Creating async methods in C# prior to version 5.0
Intuit // C# // Lecture_4 // Laba_#2
C# constructor in inheritance
321
Detaylar
a6