Showing posts with label list of odd numbers using methods in c#. Show all posts
Showing posts with label list of odd numbers using methods in c#. Show all posts

Saturday, December 17, 2016

List of Odd Numbers Using Methods in C#

In this article I would like to share with you a sample program that I wrote using methods in C# to list down the odd numbers from 250. This code will help you understand how to write a method and use of looping statement for in C# programming language.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

/* List of Odd Numbers Using Methods                */
/* Author : Mr. Jake R. Pomperada, MAED-IT           */
/* Date   : December 1, 2016    Thursday 11:20 AM    */
/* Tool   : C#                                      */

namespace list_odd_numbers
{

    class list_odd_numbers
    {
       // Method Check_Odd_Numbers

        public static bool Check_Odd_Numbers(int  value)
        {
            return value % 2 != 0;
        }

          static void Main(string[] args)
            {
            

            Console.Write("\n\n");
            Console.Write("\t\t LIST OF ODD NUMBERS USING METHODS ");
            Console.Write("\n\n");
            for (int a = 0; a <= 250; a++)
            {
                if (Check_Odd_Numbers(a))
                {
                    Console.Write(" {0} ",a);
                }
            }

            Console.Write("\n\n\n");
            Console.Write("\t\t Thank You For Using This Software.");
            Console.Write("\n\n");
            Console.ReadLine();
        }
    }
}