Sunday, July 25, 2010

Types of JIT Compiler

JIT (Just In Time) compiler converts non executable (MSIL) code to executable (native) code.This process is also called Dynamic Translation.
Following are the types of JIT compiler.

(1) PRE JIT Compiler
(2) ECONO JIT Compiler
(3) NORMAL JIT compiler

(1) PRE JIT Compiler

Pre-JIt compiler compiles complete source(MSIL)code to Native code in a single Compilation.

(2) ECONO JIT Compiler :

This compiler compiles only MSIL code of those methods that are called at Runtime.

(3) NORMAL JIT compiler:

This compiler compiles only MSIL code of those methods that are called at runtime and that converted (native) code is stored in cache.This happens because,when these methods called again it will retrieve code from cache itself without sending request to CLR.Thus,in turn saves much of executiom time

Saturday, July 24, 2010

Program to get data from user and store in STUDENT file, again read it from STUDENT file and write to DATA file and display same on screen ( GTU Sem I Program No : 41)

/*Program to get student data from user,
  write it to STUDENT file , read it again in
  store in DATA file and display same on screen
  Program No   : 41 of GTU Practice Programs SEM I
  Developed by : Malhar Vora
  Developed on : 21/07/2010
  Email        : vbmade2000@gmail.com
  Web Site     : http://malhar2010.blogspot.com
**************************************************/


struct studata
{
   int rollno;
   char name[20];
};

typedef struct studata student;
student s;

//Get Student data from user
void readData()
{
    short temp;
    printf("Enter Roll No of Student :");
    scanf("%d",&temp);
    s.rollno=temp;

    fflush(stdin);
    printf("\nEnter Name of Student :");
    gets(s.name);

}

//Write inputted data to STUDENT file
void writeStudentFile()
{
   FILE *stufile;
   stufile=fopen("STUDENT","wt");
   if(stufile==NULL)
   {
      printf("\nError in writing STUDENT file");
      return;
   }
   fwrite(&s,sizeof(s),1,stufile);
   fclose(stufile);
}

//Clear structure s to hold new data
void clearData()
{
   s.rollno=0;
   strcpy(s.name,"");
}

//Read data from STUDENT file
void readStudentFile()
{
   FILE *stufile;
   stufile=fopen("STUDENT","rt");
   if(stufile==NULL)
   {
      printf("\nError in reading STUDENT file");
      return;
   }
   fread(&s,sizeof(s),1,stufile);
   fclose(stufile);
}

//Write data to DATA file
void writeDataFile()
{
   FILE *datafile;
   datafile=fopen("STUDENT","wt");
   if(datafile==NULL)
   {
      printf("\nError in writing DATA file");
      return;
   }

   fwrite(&s,sizeof(s),1,datafile);
   fclose(datafile);
}

//Display data fetched from STUDENT file
void displayData()
{
   printf("\nData from STUDENT file");
   printf("\nRoll No : %d",s.rollno);
   printf("\nName    : %s",s.name);
}

void main()
{
  clrscr();
  readData();
  writeStudentFile();
  clearData();
  readStudentFile();
  writeDataFile();
  displayData();
}


Thursday, July 22, 2010

Program to display size of int,float and double variables ( GTU Sem I Program No : 24)

/*Program to print the size of int,float and double variables
  Program No   : 24 of GTU Practice Programs
  Developed by : Malhar Vora
  Developed on : 20/07/2010
  Email        : vbmade2000@gmail.com
  Web Site     : http://malhar2010.blogspot.com
****************************************************************************/


#include

void main()
{
   int i=1;
   float f=2.5;
   double d=2.60;
 
   printf("Size of int is %d",sizeof(i));
   printf("\nSize of int is %d",sizeof(f));
   printf("\nSize of int is %d",sizeof(d));

} 


Program to create linear linked list and print contents and total items( GTU Sem I Program No : 42)

/*Program to create a linear linked list interactively and print its
  content and total no of items in list
  Program No   : 42 of GTU Practice Programs SEM I
  Developed by : Malhar Vora
  Developed on : 20/07/2010
  Email        : vbmade2000@gmail.com
  Web Site     : http://malhar2010.blogspot.com
****************************************************************************/


#include

#define LIMIT 5

//structure to hold data and link to next node
struct node
{
   int data;
   struct node *next;
};


short count=0; //Gloab lcounter to count no of items in list
typedef struct node *listnode;

listnode root=NULL;

void insert(int newdata)
{
    listnode newnode,temp;
    newnode=(listnode)malloc(sizeof(listnode));
    newnode->data=newdata;
    temp=root;
    while(temp->next!=NULL)
    {
       temp=temp->next;
    }
    temp->next=newnode;
    newnode->next=NULL;
    count++;
}

void print()
{
   listnode temp;
   temp=root;
   printf("\nPrinting items");
   while(temp->next!=NULL)
   {
       temp = temp->next;
       printf("\n%d",temp->data);
   }
}

void printcount()
{
   printf("\nTotal %d items are stored in linked list",count);
}

void main()
{
   clrscr();
   insert(1);
   insert(2);
   insert(3);
   insert(4);

   print();

   printcount();

}

Program to find maximum element from 1D array ( GTU Sem I Program No : 19)

/*Program to find maximum element from 1D array
  Program No   : 19 of GTU Practice Programs SEM I
  Developed by : Malhar Vora
  Developed on : 20/07/2010
  Email        : vbmade2000@gmail.com
  Web Site     : http://malhar2010.blogspot.com
****************************************************************************/


#include

#define LIMIT 5

int getMax(int *arr,int n)
{
   int i,max;
   max=arr[i];
   for(i=0;i
   {
      if(arr[i]>max)
     max=arr[i];
   }
   return max;
}

void main()
{
   int arr[LIMIT],i,max=0;
   clrscr();

   printf("Enter elements in array :");
   for(i=0;i
   {
      scanf("%d",&arr[i]);
   }


   printf("Max is : %d",getMax(arr,LIMIT));

}

Function to check that no is prime or not ( GTU Sem I Program No : 30)

/*Write a fucntion prime which returns 1 is argument is prime no otherwise 0
  Program No   : 30 of GTU Practice Programs
  Developed by : Malhar Vora
  Developed on : 20/07/2010
  Email        : vbmade2000@gmail.com
  Web Site     : http://malhar2010.blogspot.com
****************************************************************************/


#include


short prime(int no)
{
    if(no % 2==0)
       return 0;
    else
       return 1;
}


void main()
{
   int no;
   printf("Enter a no :");
   scanf("%d",&no);
   if(prime(no)==1)
   {
      printf("\nNo is prime");
   }
   else
   {
      printf("\nNo is not prime");
   }

} 


Program to count length of given string ( GTU Sem I Program No : 23)

/*Program to find length of inputted string
  Program No   : 23 of GTU Practice Programs
  Developed by : Malhar Vora
  Developed on : 20/07/2010
  Email        : vbmade2000@gmail.com
  Web Site     : http://malhar2010.blogspot.com
****************************************************************************/


#include 

int strlen(char *str)
{
    int count=0;
    while(str[count]!=0)
      count++;
    return count;
}

void main()
{
   char *str;
   printf("Enter a string :");
   gets(str);
   printf("\nLength of string is : %d",strlen(str));
} 


My first OpenSource initiative

Recently during my study i developed C++ port of some functionality available in .Net languages. I was already familiar with some of the .Net port of applications and frameworks available for Java such as NUnit and NAnt. So i have decided to develop some of the classes in C++ which are available in .Net . I have uploaded classes to here.Feel free to download and use these classes.I am a beginner level programmer so there is possibility for classes to contain errors so if you find any error and or have any suggestion, just mail me at vbmade2000@gmail.com.