Monday, 17 February 2014

Function Having return type

   struct Square
        {
            int SquareMe(int x)
            {
       
                int s;
            
                Console.WriteLine ("I am Squaring You");
                s = x * x;
                return s;
            }


           static void Main()
            {
                int n, s1=0;
                Square o = new Square();

                for (int i = 1; i <= 5; i++)
                {
                    Console.WriteLine("Enter Any Number");
                    n = int.Parse(Console.ReadLine());
                    s1 = o.SquareMe(n);
                    Console.WriteLine("Square of {0} is {1}", n, s1);
                   
                }
               
                Console.WriteLine("Press any key to Exit");
                Console.ReadKey();
            }
        }

No comments:

Post a Comment