next


ElseIF Condition
Conditional

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

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {

            int x, y, z;
            Console.WriteLine("enter x,y z values");

            x = Convert.ToInt32(Console.ReadLine());
            y = Convert.ToInt32(Console.ReadLine());
            z = Convert.ToInt32(Console.ReadLine());

            if (x > y && x > z)
            {
                Console.WriteLine("x is max");
            }
            else if (y > x && y > z)
            {
                Console.WriteLine("y is max");
            }
            else if (z > y && z > x)
            {
                Console.WriteLine("Z is max");
            }
            else
            {
                Console.WriteLine("all are  equal");
            }
            Console.Read();

        }
    }
}

Nested IF Condition

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

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {

            int x;
            Console.WriteLine("enter x value");

            x = Convert.ToInt32(Console.ReadLine());
            if (x > 0)
            {
                if (x > 20 && x < 30)
                {
                    Console.WriteLine("valid");
                }
                else
                {
                    Console.WriteLine("invalid");
                }
            }

            else
            {
                Console.WriteLine("pls enter positive  number");
            }

            Console.Read();

        }
    }
}

Vowel Consonant Program Using Nested If( Character Must Be Small Letter )

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

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {

            char x;
            Console.WriteLine("Enter Character");
            x = Convert.ToChar(Console.ReadLine());

            if(x>='a' && x<='z')
            {
            if (x=='a' || x=='e' || x=='i' || x=='o' || x=='u' )
            {
                Console.WriteLine("vowel");
            }
            else
            {
                Console.WriteLine("consonant");
            }

            }
            else{
                Console.WriteLine("pls enter small letter only");
            }
      
         Console.Read();
        

        }
    }
}


ODD or EVEN number Using Switch

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

namespace ConsoleApplication10
{
    class Program
    {
        static void Main(string[] args)
        {
            int x;
            Console.WriteLine("enter x value");
            x = Convert.ToInt32(Console.ReadLine());
            int y=x%2;
            switch(y)
            {
                case 0:
                    Console.WriteLine("even number");
                    break;
                case 1:
                    Console.WriteLine("odd Number");
                    break;
                default:
                    Console.WriteLine("invalid choice");
                    break;
            }
            Console.Read();


        }
    }
}

Vowel Consonant Program Using Switch

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

namespace ConsoleApplication10
{
    class Program
    {
        static void Main(string[] args)
        {
            char ch;
            Console.WriteLine("Enter Character");
            ch = Convert.ToChar(Console.ReadLine());

            switch(ch)
            {
                case 'a':
                case 'e':
                case 'i':
                case 'u':
                case 'o':
                    Console.WriteLine("Vowel");
                    break;
                default:
                    Console.WriteLine("Consonant");
                    break;


            }
            Console.Read();


        }
    }
}

Vowel And Consonant Using Switch ( If Character Must Be Lower Case Letter )
www

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

namespace ConsoleApplication10
{
    class Program
    {
        static void Main(string[] args)
        {
            char ch;
            Console.WriteLine("Enter Character");
            ch = Convert.ToChar(Console.ReadLine());
            if(ch>='a' && ch<='z')
            {
            switch(ch)
            {
                case 'a':
                case 'e':
                case 'i':
                case 'u':
                case 'o':
                    Console.WriteLine("Vowel");
                    break;
                default:
                    Console.WriteLine("Consonant");
                    break;


            }
            }
            else
            {
                Console.WriteLine(" pls enter small letter");
            }
            Console.Read();


        }
    }
}

Display Employee Details

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

namespace ConsoleApplication10
{
    class Program
    {
        static void Main(string[] args)
        {
          int age;
          decimal salary;
          String name;
          char gender;
          Console.WriteLine("Enter Name");
          name=Console.ReadLine();
          Console.WriteLine("Enter Salary");
          salary=Convert.ToDecimal(Console.ReadLine());
          Console.WriteLine("Enter AGE");
          age=Convert.ToInt32(Console.ReadLine());
          Console.WriteLine("Enter Gender");
          gender=Convert.ToChar(Console.ReadLine());
          Console.WriteLine("Name of the person is "+name);
          Console.WriteLine("Age of the person is "+age);
          Console.WriteLine("Gender of the person is "+gender);
          Console.WriteLine("Salary of the person is "+salary);
          Console.Read();
                

        }
    }
}

Display 1 to 10 Values Using For Loop
For Loop

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

namespace ConsoleApplication10
{
    class Program
    {
        static void Main(string[] args)
        {
            int x;
            for (x=1;x<=10;x++)
            {
                Console.WriteLine(x);
            }

            Console.Read();

        }
    }
}

Display 10 to 1 Values Using For Loop

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

namespace ConsoleApplication10
{
    class Program
    {
        static void Main(string[] args)
        {
            int x;
            for (x=10;x>=1;x--)
            {
                Console.WriteLine(x);
            }

            Console.Read();


        }
    }
}

Display A To Z Using For Loop

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

namespace ConsoleApplication10
{
    class Program
    {
        static void Main(string[] args)
        {
            char ch;
            
            for (ch='A';ch<='Z';ch++)
            {
                Console.WriteLine(ch);
            }

            Console.Read();


        }
    }
}

Factorial Number

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

namespace ConsoleApplication12
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, fact = 1, n;
            Console.WriteLine("enter n value");
            n = Convert.ToInt32(Console.ReadLine());
            for (x = 1; x <= n; x++)
            {
                fact = fact * x;
            }
            Console.WriteLine(fact);
            Console.Read();

        }
    }
}

Factorial of N Numbers

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

namespace ConsoleApplication12
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, fact = 1, n;
            Console.WriteLine("enter n value");
            n = Convert.ToInt32(Console.ReadLine());
            for (x = 1; x <= n; x++)
            {
                fact = fact * x;

                Console.WriteLine(fact);
            }
            Console.Read();

        }
    }
}

Sum Of Natural Numbers
                      
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication10
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, sum = 0;
            for (x = 10; x >= 1; x--)
            {
                sum = sum + x;
            }
            Console.WriteLine(sum);

            Console.Read();
        }

        
    }
}

Sum Of Even Numbers

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

namespace ConsoleApplication10
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, sum = 0;
            Console.WriteLine("Enter N value");
            int n = Convert.ToInt32(Console.ReadLine());
            for (x = n; x >= 1; x--)
            {
                if (x % 2 == 0)
                {
                    sum = sum + x;
                }
            }
            Console.WriteLine(sum);

            Console.Read();
        }

        
    }
}

Sum of Odd Numbers

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

namespace ConsoleApplication10
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, sum = 0;
            Console.WriteLine("Enter N value");
            int n = Convert.ToInt32(Console.ReadLine());
            for (x = n; x >= 1; x--)
            {
                if (x % 2 != 0)
                {
                    sum = sum + x;
                }
            }
            Console.WriteLine(sum);

            Console.Read();
        }

        
    }
}

Sum Of Even Or Odd Numbers Based On The N value

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

namespace ConsoleApplication10
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, sum = 0;
            Console.WriteLine("Enter N value");
            int n = Convert.ToInt32(Console.ReadLine());
            if (n % 2 == 0)
            {
                for (x = n; x >= 1; x--)
                {
                    if (x % 2 == 0)
                    {
                       sum = sum + x;
                    }



                }
            }

            else
            {

                for (x = n; x >= 1; x--)
                {
                    if (x % 2 == 1)
                    {
                        sum = sum + x;
                    }



                }


            }
            Console.WriteLine(sum);
           

            Console.Read();
        }

        
    }
}

Nested For Loop

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

namespace ConsoleApplication12
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, y;

            for (x = 1; x <= 7; x++)
            {
                for (y = 1; y <= 4; y++)
                {
                    Console.Write("*");
                }
                Console.WriteLine("");

            }

            Console.Read();

        }
    }
}

Display 1 To 10 Using While Loop
While
                                
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication13
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, n;
            Console.WriteLine("enter n value");
            n = Convert.ToInt32(Console.ReadLine());
            x=1;
            while (x <= n)
            {
               
                Console.WriteLine(x);
                x++;
           
            }
            Console.Read();

        }
    }
}

While Loop (20 to 30 Between Number )
                            
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication13
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;
            Console.WriteLine("enter n value");
            n = Convert.ToInt32(Console.ReadLine());
           
            while (n<=20 || n>=30)
            {

               Console.WriteLine("enter n value again");
            n = Convert.ToInt32(Console.ReadLine());  
            }

            if (n > 20 && n < 30)
            {
                Console.WriteLine("valid");

            }
            else
            {
                Console.WriteLine("wrong");
            }
          
            Console.Read();

        }
    }
}

Factorial Number Using DO While Loop

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

namespace ConsoleApplication13
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, n;
            Console.WriteLine("enter n value");
            n = Convert.ToInt32(Console.ReadLine());
            x=1;
            do
            {
               
                Console.WriteLine(x);
                x++;
           
            }
            while (x <= n);
            Console.Read();

        }
    }
}

Continue Statement
UnConditional


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

namespace ConsoleApplication10
{
    class Program
    {
        static void Main(string[] args)
        {
            int x;
            for (x=1;x<=10;x++)
            {
            	if(x%6==0)continue;
                Console.WriteLine(x);
            }

            Console.Read();


        }
    }
}

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

namespace ConsoleApplication10
{
    class Program
    {
        static void Main(string[] args)
        {
            int x;
            for (x=1;x<=10;x++)
            {
            	if(x%6==0)break;
                Console.WriteLine(x);
            }

            Console.Read();


        }
    }
}

Write A Simple Program Without Using Main Method

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

namespace ConsoleApplication10
{
    class Program
    {
        static void Main(string[] args)
        {
            int x;
            for (x=1;x<=10;x++)
            {
            	if(x%6==0)
                {
                goto Rain
                }
                Console.WriteLine(x);
            }
            Rain:
            	x=x+100;
                Console.WriteLine(x);

            Console.Read();


        }
    }
}

Print ASCII Values.

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

namespace ConsoleApplication10
{
    class Program
    {
        static void Main(string[] args)
        {
            char ch,i;
            Console.WriteLine("Enter Character");
            ch=Convert.ToChar(Console.ReadLine());
            
            if(ch>='a' && ch<='z')
            {
            for(i='a';i<='z';i++)
            {
            Console.WriteLine(i+"="+(int)i);
            }
            }
            else
            {
            for(i='A';i<='Z';i++)
            {
            Console.WriteLine(i+"="+(int)i);
            }
            }
        }
     }
  }