বৃহস্পতিবার, ২৪ এপ্রিল, ২০১৪

Difference between do while loop and while loop


Difference between do while loop and while loop


do while loop:

Though the condition of the loop is false, it goes inside of the loop.  The do while loop executes the content of the loop once without checking the condition of the while.

while loop:

Whereas a while loop will check the condition first before executing the content.If the condition is false, it does not go inside of the loop;


1
do while loop
while loop
2

int  len;
do {
        printf(" length... ");
        scanf("%d", &len);
    } while(len<2);

int  len;

while(len<2){
        printf(" length... ");
        scanf("%d", &len);
         } 

Example of Virtual Function

//Visual Studio .NET, C#

//Virtual methods


using System;
class CLASS1
{
   public void F() { Console.WriteLine("One"); }
   public virtual void G() { Console.WriteLine("Two"); }
}
class CLASS2: CLASS1
{
   new public void F() { Console.WriteLine("Three"); }
   public override void G() { Console.WriteLine("Four"); }
}
class Test
{
   static void Main() {
      CLASS2 b = new CLASS2();
      CLASS1 a = b;
      a.F();
      b.F();
      a.G();
      b.G();
   }
}

OUT PUT:
One
Three
Four
Four

বৃহস্পতিবার, ২৬ সেপ্টেম্বর, ২০১৩

**p


pointer to pointer in c

**p


#include <stdio.h>
#include<conio.h>
void main ()
{
int p, *fpointer, **spointer;
clrscr();

p = 1000;
fpointer = &p; // fpointer puts the address of p.
spointer = &fpointer; // spointer puts the address of fpointer.

printf(“Value of p : %d”, p);
printf(“\n”);
printf("Value of *fpointer : %d" *fpointer”);
printf(“\n”);
printf(“"Value of **spointer : %d" **spointer);
getch();
}
The result is:
Value of p :1000
Value of *fpointer :1000
Value of **spointer :1000