Wednesday, 17 October 2012

How to print Fibonacci series in c# Using For Loop


How to print Fibonacci series in c# Using For Loop


Code Sample:
using System;
using System.Collections.Generic;
using System.Text;
namespace fibseries
{
class Program
    {
        static void Main(string[] args)
        {
            int num; 
            Console.WriteLine("Please Enter a number:"); 
             num = Convert.ToInt32(Console.ReadLine()); 
             Console.WriteLine("\n"); 
             Console.WriteLine("The first " + num + " number(s) in the fibonacci series are: ");
             FibonacciSeries(num); 
             Console.Read(); 
        }
        // Fibonacci Code
        public static int FibonacciSeries(int n) 
        { 
             int previous = -1; 
             int next = 1; 
             for (int i = 0; i < n; i++) 
             { 
                 int sum = next + previous; 
                 previous = next; 
                 next = sum; 
                 Console.WriteLine(next); 
             } 
             return next;    
         } 
    }

Change View of SharePoint Calendar using javascript/JQuery


Change View of SharePoint Calendar using javascript/JQuery

<script type="text/javascript">
    $(document).ready(function () {
 
        $("#btnMonth").click(function () {
            MoveView('month')
        });
        $("#btnday").click(function () {
            MoveView('day');
        });
        $("#btnweek").click(function () {
            MoveView('week');
        });

    });
   </script>
   <div style="float:right;">
<input id="btnday" value="Day" type="button" />

<input id="btnweek" value="Week" type="button" />

<input id="btnMonth"  value="Month" type="button" />
</div>

Tuesday, 16 October 2012

c# program to print patterns of numbers and stars(pyramid)


These program prints various different patterns of numbers and stars. These codes illustrate how to create various patterns using c programming. Most of these c programs involve usage of nested loops and space. A pattern of numbers, star or characters is a way of arranging these in some logical manner or they may form a sequence. Some of these patterns are triangles which have special importance in mathematics. Some patterns are symmetrical while other are not. Please see the complete page and look at comments for many different patterns.
    *
   ***
  *****
 *******
*********
We have shown five rows above, in the program you will be asked to enter the numbers of rows you want to print in the pyramid of stars.

C programming code

class Program
    {
        static void Main(string[] args)
        {
            int row,c,n,temp;
            n = 5;
           temp= n ;
           for (row = 1; row <= n; row++)
           {
               for (c = 1; c < temp; c++)
                   Console.Write(" ");
               
               temp--;
               for (c = 1; c <= 2 * row - 1; c++)
                   Console.Write("*");

               Console.WriteLine();
           
           }


            
        }
    }