Archive for December 2011

#include<stdio.h>

#include<conio.h>

void main()

{

clrscr();

int a,b;

printf(“enter the number:-”);

scanf(“%d”,&a);

printf(“enter the number:-”);

scanf(“%d”,&b);

if(a==b)

{

printf(“a,b are equal”);

}

else

{

if(a>b)

{

printf(“a is max”);

}

else

{

printf(“b is max”);

}

}

getch();

}

No tags Hide

·       Viewstate is one of the most important and useful client side state management mechanisms.

·       It can store the page value at the time of post back of your page.

·       ASP.NET pages provide the View State property as a built-in structure for automatically storing values between multiple requests for the same page.

·       There are two level of view state:

1.     Page level

2.     Control level

·       Page Level view state control treat as highest priorities.

·       Which means If we set EnableViewState= “False” in page level, that will automatically be derived by all the server side controls. In that case, if we set  EnableViewState=”True”  for any server side control will treat it as false, as we have defined them “False” in Page Level.

·       Apply the view state at page level:

o     Page level means apply viewstate property to page.

o     To apply the viewstate at page level set the property  EnableViewState  of  page

o     Now , if set the EnbleViewState property = “true” then all the server control derived this property as true.

o     If we set the EnbleViewState property = “false” then all the server control derived this property as false.

·       Apply the view state at control level:

o     Control level means apply viewstate property on controls used in page.

o     To apply the viewstate at control level then set the enableviewstate property of each control on which you want to set.

o     Ex. <asp:DropDownList ID=”DropDownList1″ runat=”server” EnableViewState=”true”> </asp:DropDownList>

o     If you apply page level as false then this property will not work because pagelevel has high priority.

Hide

Break and Continue statement are jumping statement. Java supports following three jumping statements:

1.      Break

2.      Continue

3.      Return

 

Break : -

The break statement has three uses :

a)      It terminates a statement sequence in a switch statement

b)      It can be used to exit a loop

c)      It can be used as a “civilized” form of goto

 

Example :

Terminates a statement sequence in a switch statement :

 

When a break statement is encountered, execution branches to the first line of code that follows the entire switch statement.

 

Class switching

{

Public static void main (String args[])

{

                                              Switch (wash)
                                              {
                                                 case 1:
                                                             System.out.println("Cotton selected");
                                                             break;
                                                 case 2:
                                                             System.out.println("Linen selected");
                                                             break;
                                                 case 3:
                                                      System.out.println("Wool selected");
                                                             break;
                                                 default:
                                                      System.out.println("Selection error");
                                                             break;
                                              }
                                           }
                                     }




Using break to exit a loop

                      Using break, you can  force immediate termination of a loop by passing the conditional
expression and any remainder code in the body of the loop.


    Class exloop
             {
                      Public static void main (String args[])
                      {
                                     For (i=0;i<=10;i++)
                                     {
                                       If (i==5)
                                                    Break;
                                       System.out.println(i)
                                     }
                      }
             }

Using break as form of goto:

                      Java does not have a goto statement because it provides a way to
branch in an arbitrary and unstructured manner. Using break, you can break out of any block.
Break works with label. General form of the labelled break is
                                     Break label;
When labelled break executes, control is transferred out to named block.

       Class breaklabel
       {
                      Public static void main (String args[])
                      {
                                     Boolean t=true;
                                     First :
                                     {
                                       Second :
                                            {
                                             Third :
                                                    {
                                                    System.out.println(“Before Break”);
                                                    If (t) break second;
                                                    System.out.println(“No Use”);
                                                    }
                                             System.out.println(“No Use”);
                                            }
                                        System.out.println(“This is after use”);
                                     }
                      }
       }

Continue:

                   Continue statement is used to continue running the loop but stop processing the
remainder of the code in its body for this particular iteration.
                   In while and Do-While loop, a continue statement causes control to be transferred
directly to the conditional expression that controls the loop.
                   In For loop control goes first to iteration portion of the for statement and then
to the conditional expression.

                   Example:
                     Class continueuse
                     {
                                  Public static void main ( String args[])
                                  {
                                    For ( int i=0;i<10;i++)
                                    {
                                      System.out.println(I + “ “);
                                     If (i%2==0)
                                                 Continue;
                                     System.out.println(“ “);
                                    }
                                  }
                   }

Hide

« Previous

Next »

Managed by

MNP INFOTECH