Thursday, 12 January 2017

Fibonacci Series using for loop in C#

using System;


    class Fibonacci
    {
        static void Main()
        {
            Console.WriteLine("Enter First No");
            int num1 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter Second No");
            int num2 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter no of iteration you need");
            int range = Convert.ToInt32(Console.ReadLine());
            int result = 0;
            Console.WriteLine(num1);
            Console.WriteLine(num2);
            for (int i = 0; i <= range; i++)
            {

                result = num1 + num2;
                Console.WriteLine(result);
                num1 = num2;
                num2 = result;
            }
            Console.ReadLine();

        }
    }
 Dry run: 
DRY RUN
NOI=10 num1=1 num2=2
No Of Iteration num1 num2 Result
1 1 2 3
2 2 3 5
3 3 5 8
4 5 8 13
5 8 13 21
6 13 21 34
7 21 34 55
8 34 55 89
9 55 89 144
10 89 144 233
 Output:-Enter First No
1
Enter Second No
2
Enter no of iteration you need
10
1
2
3
5
8
13
21
34
55
89
144
233
377

Loop: - Loop is mechanism which used to execute your statement till the condition become false.
Further loop can categories into two. 1)Range Based and 2)Condition Based.




                                                                                                                                          

Range Based:- In this case user/developer must aware range of iteration.  
Iteration 0 to 10.in this scenario we will go for loop.
For Loop:- This loop repeatedly executes  a group of  statements as long as a condition not become false.
Syntax:-for( int i=0;i<10;i++ or--)
{ Operation
}
For loop consist three importance parts.
1)      Initialization
2)      Condition
3)      Increment/ decrement.
Eg:-
( int i=0;i<10;i++ or--)
1       2            3


 .

















Tuesday, 10 January 2017

Check Whether an Alphabet is Vowel or Consonant using C#

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

namespace SwitchCase
{
    class Switch
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter a Character");
            char ch = Convert.ToChar(Console.ReadLine());
            switch (ch)
            {
                case 'a':
                    Console.WriteLine("Vowel");
                    break;
                case 'e':
                    Console.WriteLine("vowel");
                    break;
                case 'i':
                    Console.WriteLine("Vowel");
                    break;
                case 'o':
                    Console.WriteLine("Vowel");
                    break;
                case 'u':
                    Console.WriteLine("Vowel");
                    break;
                default:
                    Console.WriteLine("consonant");
                    break;
                             
                    }
            Console.ReadLine();
        }
    }
}

Wednesday, 28 December 2016

Data validation using Java script with event handling.

HTML
--------------------------------------------------------------------------------------------------------------------
<html>

<head>
    <title>Registration</title>
    <link rel="stylesheet" href="Custom.css">
</head>

<body>
    <h1 class="heading">Our Financial Status</h1>

    <table class="frm">

        <tr>
            <td>
                   First Name  
            </td>
            <td>
                <input type="text" placeholder="First Name" id="txtFirstName">
            </td>
        </tr>


        <tr>
            <td>
                   Last Name  
            </td>
            <td>
                <input type="text" placeholder="Last Name" id="txtLastName">
            </td>
        </tr>


        <tr>
            <td>
                   Email Id  
            </td>
            <td>
                <input type="text" placeholder="Email" id="txtEmail">
            </td>
        </tr>


        <tr>
            <td>
                    Password  
            </td>
            <td>
                <input type="password" placeholder="Password" id="txtPassword">
            </td>
        </tr>


        <tr>
            <td>
                    Mobile No  
            </td>
            <td>
                <input type="text" placeholder="Mobile" id="txtMobileNo">
            </td>
        </tr>


        <tr>
            <td>
                    Pan Card No  
            </td>
            <td>
                <input type="text" placeholder="PanCard" id="txtPancard">
            </td>
        </tr>


        <tr>
            <td>
                   Aadhar Card No  
            </td>
            <td>
                <input type="text" placeholder="Aadhar Card" id="txtAadharCard">
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="submit" value="Submit" id="btnSubmit"  class="button">
            </td>
        </tr>
    <table>
          <script src="Registraion.js"></script>
</body>

</html>
----------------------------------------------------------------------------------------------------
CSS
------
body {
  font: 14px/20px 'Helvetica Neue', Helvetica, Arial, sans-serif;
  color: #404040;
  background: #2d4259;
}
.heading
{
width: 270px;
  line-height: 43px;
  margin: 50px auto 20px;
  font-size: 19px;
  font-weight: 500;
  color: white;
  color: rgba(white, .95);
  text-align: center;
  text-shadow: 0 1px rgba(black, .3);
  background: #d7604b;
  border-radius: 3px;
 }
 .frm{
  margin: 0 auto;
  width: 375px;
  padding: 20px;
  background: #f4f4f4;
  border-radius: 3px;
 }
 .input{
      display: block;
  width: auto;
  height: 50px;
  margin-top: 2px;
  font-weight: 500;
  background: none;
  border: 0;
  border-bottom: 1px solid #d8d8d8;
 }
 .label {
  float: left;
  width: 50%;
  line-height: 32px;
  color: white;
  text-align: center;
   cursor: pointer;
 }
.button {
  display: block;
  width: 100%;
  height: 42px;
  margin-top: 25px;
  font-size: 16px;
  font-weight: bold;
  color: #494d59;
  text-align: center;
  text-shadow: 0 1px rgba(white, .5);
  background: #fcfcfc;
  border: 1px solid;
  border-color: #d8d8d8 #d1d1d1 #c3c3c3;
  border-radius: 2px;
  cursor: pointer;

  }
---------------------------------------------------------------------------------------------------------------
Java Script
----------------------
function dataValidation()
{
    var firstName=document.getElementById("txtFirstName");
    var lastName=document.getElementById("txtLastName");
    var emailID=document.getElementById("txtEmail");
    var passward=document.getElementById("txtPassword")
    var mobileNo=document.getElementById("txtMobileNo");
    var panCard=document.getElementById("txtPanCard");
    var aadharCard=document.getElementById("txtAadharCard");
    var btnSubmit=document.getElementById("btnSubmit");
    btnSubmit.addEventListener("click",UserRegistration);
    firstName.addEventListener("keypress",alphabet);
    lastName.addEventListener("keypress",alphabet);
    emailID.addEventListener("keypress",alphanumeric);
    passward.addEventListener("keypress",alphanumeric);
    mobileNo.addEventListener("keypress",numeric);
    panCard.addEventListener("keypress",alphanumeric);
    aadharCard.addEventListener("keypress",numeric);
}
function UserRegistration()
{
  console.log(this);
}
function alphabet(evnt)
{
 console.log(this);
 console.log(evnt);
 var dataLength = this.value.length;
 console.log(dataLength);
    if((evnt.keyCode>=65 && evnt.keyCode<=90) ||
        (evnt.keyCode>=97 && evnt.keyCode<=122)){

    }
    else{
        alert("only alphabet[a-z or A-Z]");
        evnt.preventDefault();
    }

}
function numeric(evnt)
{
 var dataLength = this.value.length;
if((evnt.keyCode >=48 && evnt.keyCode<=57)&&(this.value.length !=10))
    {

    }        
       else
       {
            alert("only number and not than 10 digits");
      evnt.preventDefault();
         }
        }

function alphanumeric(evnt)
{

if(((evnt.keyCode >=65 && evnt.keyCode <=90) ||
   (evnt.keyCode >=48 && evnt.keyCodeode<=57) 
    &&(thi.value.length !=10)))
 {

   }
   else{
       alert("It allow not capital letter, [0-9 ] and not greather than 10 character");
        evnt.preventDefault();
   }
}

function alphnumericWithspecialcharacters(evnt)
{
        
        if(((
        (evnt.keyCode>=65 && evnt.keyCode<=90) ||
        (evnt.keyCode>=97 && evnt.keyCode<=122)||
        (evnt.keyCode >=48 && evnt.keyCodeode<=57)&&
        (this.value.length<=10 || this.value.length>=20)
       
        )))
        {

        }
        else{
             alert("It allow not [A-Z, a-z,0-9 ] and not <10 || >20 character");
             evnt.preventDefault();
        }
//Note: I want add following Special Characters in this function.
//  Ascii Value
//  45      -
//  46      .
//  64      @
//  95      _
}
dataValidation();  



Please give your comment

Tuesday, 27 December 2016

armstrong number in c

#include<stdio.h>
int main()
{
     int num, sum = 0;
         

    printf("Please enter a number: ");      
    scanf("%d",&num);

     for (int i = num; i > 0;)
            {
                sum += (i % 10) * (i % 10) * (i % 10);
                i = i / 10;

            }
 if ( sum==num)
        printf("%d is an armstrong number.",num);
    else
        printf("%d is not an armstrong number.",num);

    return 0;
}

Check Armstrong Number using C#

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
                       int num, sum = 0;
            num = Convert.ToInt32(Console.ReadLine());
            for (int i = num; i > 0;)
            {
                sum += (i % 10) * (i % 10) * (i % 10);
                i = i / 10;

            }
            if(sum==num)
                {
                    Console.WriteLine("No is armstrong");
                }
                else
                {
                    Console.WriteLine("No is not armstrong ");
                }
                Console.ReadLine();
            }

            }
}

Thursday, 2 April 2015

Date Time culture

  System.Threading.Thread.CurrentThread.CurrentCulture = Fmt
        System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy"
        DTF.ShortDatePattern = "dd/MM/yyyy"

Auto Serial generate in Grid view

type this line in Item Teplate
                           <%# Container.DataItemIndex + 1 %>

Secure and Unsecure configuration in Dynamics CRM 365.

Overview : In Dynamics CRM, when we create a plugin, we sometimes need to pass data to that plugin, instead of writing this data inside the ...