You are on page 1of 2

1.Write a program for the fibonacci series is dispalyed.

The fibonacci series is the set of values which are unique and come in certain sequence Sample Code:
using System; using System.Collections.Generic; using System.Text; namespace codeforfibonacciseries { class Program { static void Main(string[] args) { int i = 0; int j = 1; int k = 1; int n = 0; int m = 0; m = Console.Read(); m++; Console.WriteLine("The Fibonacci series values are:"); Console.Write(" {0}, {1}", i,j); for (n = 0; n <= m; n++) { k = i +j; i = j; j = k; Console.Write(" {0} ", k); } } } }

2. Even or odd A sample program in C# A sample program in C# is used to find the given value is even or odd. Description: Here in this program, The conditional statement (If statement)is used with the condition (i.e) The remainder value is zero or non zero when dividing the given value by 2, Conslole.WriteLine is used to display the given value is even or odd and Console.ReadLine is used to get the input value. Sample Code:
using System; using System.Collections.Generic; using System.Text; namespace codeforevenorodd { class Program { static void Main(string[] args) { string g; int j = 0; int i; Console.WriteLine(" Enter the value: "); g = Console.ReadLine(); i = Convert.ToInt32(g); j = (i % 2); if(j == 0) {

Console.WriteLine("The given value is even "); } else { } } } Console.WriteLine("The given value is odd } ");

Sample Input_1: Enter the value: 88 Sample Output: The given value is even 3. Palindrome A sample program in C# A sample program in C# is used to find the given value is palindrome or not both for string value and numbers. Description: In this program, either string or number is taken as a input for checking palindrome. Palindrome is a specific name given for the word or number which shows the same name or number when reversed from right to left or vice-versa. While loop is used to check the given condition is palindrome or not. Conslole.WriteLine is used to display the given value is palindrome or not and Console.ReadLine is used to get the input value. Sample Code:
using System; using System.Collections.Generic; using System.Text; namespace codeforpalindrome { class Program { static void Main(string[] args) { string s1; int j = 0; int i = 0; Console.WriteLine(" Enter the value "); s1 = Console.ReadLine(); j = s1.Length; while (i != (j - 1)) { if (s1[i] == s1[j - 1]) { i++; j = j - 1; } else { Console.WriteLine(" The given value is not a palindrome"); break; } } if (i == (j-1)) { Console.WriteLine("The given value is a plaindrome"); } } } }

Sample Input_1: Enter the value: malayalam Sample Output: The given value is a palindrome.

You might also like