Write a Console Application to initialize Person Class using a Constructors


Module Module1

    Public Class Initailize_Constuctor
        Public Sub New(ByVal name As String, ByVal address As String)
            Console.WriteLine("Name of Employee is :" & name)
            Console.WriteLine("Address of Employee is :" & address)
            Console.WriteLine(" ")
        End Sub
    End Class


    Public Sub Main()
        Dim name, address As String
        Console.WriteLine("Enter name of Employee:")
        name = Console.ReadLine()
        Console.WriteLine("Enter address of Employee:")
        address = Console.ReadLine()
        Console.WriteLine(" ")
        Console.WriteLine(" ")
        Dim emp_obj As New Initailize_Constuctor(name, address)
        Console.ReadLine()
    End Sub

End Module

Read more...

compiler design TUTORIAL RKU

  •  TUTORIAL : 1 compiler design lexical analysis program in C  <Click here>
    • ASSIGNMENT : 1
      Q.1) What do you mean by front end and back end of compiler?   
      Q.2) How it is possible to have compiler written in c language?          Q.3)What do you mean by syntax, semantic and pragmatics of compiler?           
      Q.4) Differentiate call by value, call by reference and call by name?          
      Q.5) What are the problem faced in dynamic binding?         
      Q.6) State difference between intermediat code generation and phase of  compiler?         
      Q.7)What is pass of compiler? What are the factors are affected number of passes of compiler?        
      Q.8)What is the benifit having cross compiler?        
      Q.9) Which of the following expression have L-value or R-value.        Q.10)Why 2-pass compiler is known as a conventional compiler?


       

     

Read more...

compiler design lexical analysis program in C

#include<stdio.h>
#include<conio.h>
#include<ctype.h>

void main()
{
    char str[100],str1[100],str2[100],var[100];
    int i=0,l,l1,j=0,k=0,n,d=0;
    static int m=0;
    char key[100][100]={"int","float","char","double","if","else","for","while","do","auto","break","case","const","switch","continue","enum","extern","goto","short","register","return","sizeof","static","struct","typedef","unioun","void","volatile","while","signed","unsigned","default"};

    clrscr();

    printf("Enter the string : ");
    gets(str);

    printf("\n  Symbol    \t\tType \t\t\tNo.");

    while(str[i]!='\0')
    {
        while(isspace(str[i]))

            i++;
        switch(str[i])
        {
        case ';':
        case ',':
        case '"':
        case ':':
        case '.':
             n=1;
             printf("\n   %c    \t\tPunctual symbol\t\t%d",str[i],n);
             i++;
             break;

        case '#':
        case '$':
        case '`':
        case '@':
            n=7;
            printf("\n   %c    \t\tTropical symbol\t\t%d",str[i],n);
            i++;
            break;


        case '~':n=2;
                printf("\n      ~     \t\tBitwise not Operater\t\t%d",n);
                break;
           case '?':
              n=2;
                if(str[(i+1)]==':')
                {
                    printf("\n   ?:    \t\tconditional Operator \t\t%d",n);
                    i=i+2;
                }

                else
                {    printf("\n   %c    \t\tpunctuation symbol \t\t%d",str[i],n);
                    i++;

                }
                break;
        case '!':
                n=2;
                if(str[(i+1)]=='=')
                {
                    printf("\n   !=    \t\tNot Equal to Operator \t\t%d",n);
                    i=i+2;
                }
                else
                {    printf("\n   %c    \t\tnot Operator \t\t%d",str[i],n);
                    i++;

                }
                break;

        case '+':
                n=2;
                if(str[(i+1)]=='+')
                {
                    printf("\n   ++    \t\tincrement Operator \t\t%d",n);
                    i=i+2;
                }
                else if(str[(i+1)]=='=')
                {
                    printf("\n   +=    \t\tOperator \t\t%d",n);
                    i=i+2;
                }
                else
                {    printf("\n   %c    \t\tOperator \t\t%d",str[i],n);
                    i++;

                }
                   break;


        case '-':       n=2;
                if(str[(i+1)]=='-')
                {
                    printf("\n  --    \t\tdecrement Operator \t\t%d",n);
                    i=i+2;
                }
                else if(str[(i+1)]=='=')
                {
                    printf("\n   -=    \t\tDecrement assigment Operator \t\t%d",n);
                    i=i+2;
                }
                else
                {    printf("\n   %c    \t\tOperator \t\t%d",str[i],n);
                    i++;

                }
                break;

        case '*':  n=2;

                if(str[(i+1)]=='=')
                {
                    printf("\n   *=    \t\tMultiplication assignment Operator \t\t%d",n);
                    i=i+2;
                }
                else
                {    printf("\n   %c    \t\tMultiplication Operator \t\t%d",str[i],n);
                    i++;

                }
                break;
        case '&':  n=2;
                if(str[(i+1)]=='&')
                {
                    printf("\n   &&    \t\tAND Operator \t\t%d",n);
                    i=i+2;
                }
                else if(str[(i+1)]=='=')
                {
                    printf("\n   &=    \t\tbitwise AND assignment Operator \t\t%d",n);
                    i=i+2;
                }
                else
                {    printf("\n   %c    \t\tBitwise And Operator \t\t%d",str[i],n);
                    i++;

                }

                break;
        case '|':  n=2;
                if(str[(i+1)]=='|')
                {
                    printf("\n   ||    \t\tbitwise Or Operator \t\t%d",n);
                    i=i+2;
                }
                else if(str[(i+1)]=='=')
                {
                    printf("\n   |=    \t\tOperator \t\t%d",n);
                    i=i+2;
                }

                else
                {    printf("\n   %c    \t\tOR Operator \t\t%d",str[i],n);
                    i++;

                }  break;
        case '/':
             n=2;
                if(str[(i+1)]=='=')
                {
                    printf("\n   /=    \t\tDivision assignment Operator \t\t%d",n);
                    i=i+2;
                }
                else
                {    printf("\n   %c    \t\tDivision Operator \t\t%d",str[i],n);
                    i++;

                }   break;
          case '%':
             n=2;
                if(str[(i+1)]=='=')
                {
                    printf("\n   %=    \t\tModulo Assignment Operator \t\t %d",n);
                    i=i+2;
                }
                else
                {    printf("\n   %c    \t\tModulo Operator \t\t %d",str[i],n);
                    i++;

                }
                break;
        case '^':
             n=2;
                if(str[(i+1)]=='=')
                {
                    printf("\n   ^=    \t\tBitwise XOR assignment Operator \t\t %d",n);
                    i=i+2;
                }
                else
                {
                    printf("\n   %c    \t\tBitwise exclusive OR Operator \t\t %d",str[i],n);
                    i++;

                }
                break;


        case '<':
                n=2;
                if(str[(i+1)]=='<')
                {        printf("\n   <<   \t\tleft shift Operator \t\t%d",n);
                        i=i+2;


                }
                else if(str[(i+1)]=='=')
                {
                    printf("\n   <=    \t\tless than or equal to Operator \t\t%d",n);
                    i=i+2;
                }
                else
                {    printf("\n   %c    \t\tOperator \t\t%d",str[i],n);
                    i++;
                }
                break;
        case '>':
                n=2;
                if(str[(i+1)]=='>')
                {        printf("\n   >>    \t\tOshift right perator \t\t%d",n);
                        i=i+2;

                }
                else if(str[(i+1)]=='=')
                {
                    printf("\n   >=    \t\tgreater han or equal to Operator \t\t%d",n);
                    i=i+2;
                }
                else
                {    printf("\n   %c    \t\tOperator \t\t%d",str[i],n);
                    i++;
                }
                break;
        case '=':      n=2;
                if(str[(i+1)]=='=')
                {
                    printf("\n   ==    \t\tAssignment  Operator \t\t%d",n);
                    i=i+2;
                }
                else
                {
                    printf("\n   %c    \t\tEqual Operator \t\t%d",str[i],n);
                    i++;
                }
                break;
        case '(':
        case '{':
        case '[':
              n=4;
             printf("\n   %c    \t\tOpening bracket \t\t%d",str[i],n);
             i++;
             break;
        case '}':
        case ']':
        case ')':
             n=4;
             printf("\n   %c    \t\tClosing bracket \t\t%d",str[i],n);
             i++;
             break;


     default:         if(isalpha(str[i]))
             {
                k=0;

                while(isalnum(str[i]))
                {
                    str1[k]=str[i];
                    i++;
                    k++;
                }

                str1[k]='\0';
                l=0;

                while(j<100)
                {
                    if (strcmp(str1,key[j])==0)
                    {
                        l=1;
                        break;

                    }
                    j++;
                }

                if(l==1)
                {
                    n=3;
                    printf("\n   %s    \t\tKeyword \t\t%d",str1,n);
                }
                else
                {

                    n=4;
                    printf("\n   %s    \t\tVariable \t\t%d",str1,n);
                    l=0;
                    while(str1[l]!='\0')
                    {
                        var[m++]=str1[l];
                        l++;
                    }

                }



             }
             else if (isdigit(str[i]))
             {
                k=0;
                while(isalnum(str[i]) || str[i]=='.')
                {
                    if(str[i]=='.')
                        d++;
                    str2[k]=str[i];
                    i++;
                    k++;
                }
                str2[k]='\0';
                n=5;
                printf("\n   %s    \t\tDigit \t\t\t%d",str2,n);

                break;

             }

             else
             {
                  //    printf("\nError");
                i++;
                break;
             }
        }

    }
    var[m]='\0';
    printf("\n%s",var);
getch();
}

Read more...

write a console application to divide two number & provide error handling technique


Module Module1

    Sub Main()
        Dim a, b, c As Integer
        a = 0
        b = 100
        Try
            c = b / a
        Catch ex As Exception
            Console.WriteLine(ex.ToString())
            Console.WriteLine("divide by zero exception error")
 End Try
    End Sub

End Module

Read more...
Related Posts Plugin for WordPress, Blogger...

Engineering material

GTU IDP/ UDP PROJECT

GTU IDP/ UDP PROJECT

Patel free software download

  © Blogger templates The Professional Template by Ourblogtemplates.com 2008

Back to TOP