SlideShare a Scribd company logo
COMPLIER FILE



   Submitted by: Pinak Mukherjee (038/CS/GTBIT/04)




Department of Computer Science and Engineering

   Guru Tegh Bahadur Institute of Technology
/*Generation of code in c++ to add two numbers by coding in c*/
void main()
{char a[40],b[40],c[40],d[40];
 clrscr();
 do
 {printf("Enter class name=>");
  scanf("%s",a);
 }while(strlen(a)>=40);
 do
 {printf("Enter name of first variable=>");
  scanf("%s",b);
 }while((!strcmp(a,b))||(strlen(b)>=40));
 do
 {printf("Enter name of second variable=>");
  scanf("%s",c);
 }while((!strcmp(a,c))||(!strcmp(c,b))||(strlen(c)>=40));
 do
 {printf("Enter name of class variable=>");
  scanf("%s",d);
}while((!strcmp(a,d))||(!strcmp(d,c))||(!strcmp(d,b))||(strlen(d)>=40));
 clrscr();
 printf("class %s",a);
 printf("n{n private:n");
 printf(" int %s;n",b);
 printf(" int %s;n",c);
 printf(" public:n");
 printf(" void getinput()n {");
 printf("n cout<<"Enter first number:";");
 printf("n cin>>%s;",b);
 printf("n cout<<"Enter second number:";");
 printf("n cin>>%s;",c);
 printf("n }");
 printf("n void addnos()n {");
 printf("n cout<<"The Sum is:"<<%s+%s;",b,c);
 printf("n }");
 printf("n };");
 printf("nvoid main()n {");
 printf("n %s %s;",a,d);
 printf("n %s.getinput();",d);
 printf("n %s.addnos();",d);
printf("n }");
 getch();
}
OUTPUT
Enter class name=>student
Enter name of first variable=>a
Enter name of second variable=>b
Enter name of class variable=>student1
class student
{
 private:
  int a;
  int b;
 public:
  void getinput()
   {
   cout<<"Enter first number:";
   cin>>a;
   cout<<"Enter second number:";
   cin>>b;
   }
  void addnos()
   {
   cout<<"The Sum is:"<<a+b;
   }
 };
void main()
 {
 student student1;
 student1.getinput();
 student1.addnos();
 }
/*Generation of code in java through code in c*/
void main()
{char a[40],b[40],c[40],d[40];
 clrscr();
 do
 {printf("Enter class name=>");
  scanf("%s",a);
 }while(strlen(a)>=40);
 do
 {printf("Enter name of first variable=>");
  scanf("%s",b);
 }while((!strcmp(a,b))||(strlen(b)>=40));
 do
 {printf("Enter name of second variable=>");
  scanf("%s",c);
 }while((!strcmp(a,c))||(!strcmp(c,b))||(strlen(c)>=40));
 do
 {printf("Enter name of class variable=>");
  scanf("%s",d);
 }while((!strcmp(a,d))||(!strcmp(d,c))||(!strcmp(d,b))||(strlen(d)>=40));
 clrscr();
printf("public class %s",a);
 printf("private int %s;n",b);
 printf("private int %s;n",c);
 printf("public static void main(){n");
 printf("n System.out.println("Enter first number:");");
 printf("n cin>>%s;",b);
 printf("n System.out.println("Enter second number:");");
 printf("n cin>>%s;",c);
 printf("n System.out.println("The Sum is:",%s+%s);",b,c);
 printf("n }");
 printf("n}");
 getch();
}

OUTPUT
Enter class name=>STUDENT
Enter name of first variable=>A
Enter name of second variable=>B
Enter name of class variable=>STUDENT1
public class STUDENTprivate int A;
private int B;
public static void main(){
   System.out.println("Enter first number:");
   cin>>A;
   System.out.println("Enter second number:");
   cin>>B;
   System.out.println("The Sum is:",A+B);
 }
}
/* Program on lexical analysis */

#include"stdio.h"
#include"conio.h"
#include"string.h"
#include"ctype.h"
#define MAX 30

void main()
{
  char str[MAX];
  int state=0;
  int i=0, j, startid=0, endid, startcon, endcon;

 clrscr();

 for(j=0; j<MAX; j++)
   str[j]=NULL;     //Initialise NULL

 printf("*** Program on Lexical Analysis ***");
 printf("Enter the string: ");
 gets(str);           //Accept input string
 str[strlen(str)]=' ';

 printf("Analysis:");

 while(str[i]!=NULL)
 {
   while(str[i]==' ') //To eliminate spaces
        i++;
   switch(state)
   {
        case 0: if(str[i]=='i') state=1;    //if
                 else if(str[i]=='w') state=3; //while
else if(str[i]=='d') state=8; //do
         else if(str[i]=='e') state=10; //else
         else if(str[i]=='f') state=14; //for
         else if(isalpha(str[i]) || str[i]=='_')
         {
                  state=17;
                  startid=i;
         } //identifiers

         else if(str[i]=='<') state=19;
         //relational '<' or '<='

         else if(str[i]=='>') state=21;
         //relational '>' or '>='

         else if(str[i]=='=') state=23;
         //relational '==' or assignment '='

         else if(isdigit(str[i]))
         {
                  state=25; startcon=i;
         }
         //constant

         else if(str[i]=='(') state=26;
         //special characters '('

         else if(str[i]==')') state=27;
         //special characters ')'

         else if(str[i]==';') state=28;
         //special characters ';'

         else if(str[i]=='+') state=29;
         //operator '+'

         else if(str[i]=='-') state=30;
         //operator '-'

         break;

//States for 'if'
case 1: if(str[i]=='f') state=2;
         else { state=17; startid=i-1; i--; }
         break;
case 2: if(str[i]=='(' || str[i]==NULL)
         {
           printf("if       : Keywordn");
state=0;
           i--;
         }
         else { state=17; startid=i-2; i--; }
         break;

//States for 'while'
case 3: if(str[i]=='h') state=4;
         else { state=17; startid=i-1; i--; }
         break;
case 4: if(str[i]=='i') state=5;
         else { state=17; startid=i-2; i--; }
         break;
case 5: if(str[i]=='l') state=6;
         else { state=17; startid=i-3; i--; }
         break;
case 6: if(str[i]=='e') state=7;
         else { state=17; startid=i-4; i--; }
         break;
case 7: if(str[i]=='(' || str[i]==NULL)
         {
           printf("while : Keyword n");
           state=0;
           i--;
         }
         else { state=17; startid=i-5; i--; }
         break;

//States for 'do'
case 8: if(str[i]=='o') state=9;
         else { state=17; startid=i-1; i--; }
         break;
case 9: if(str[i]=='{' || str[i]==' ' || str[i]==NULL || str[i]=='(')
         {
           printf("do       : Keyword n");
           state=0;
           i--;
         }
         break;

//States for 'else'
case 10: if(str[i]=='l') state=11;
         else { state=17; startid=i-1; i--; }
         break;
case 11: if(str[i]=='s') state=12;
         else { state=17; startid=i-2; i--; }
         break;
case 12: if(str[i]=='e') state=13;
else { state=17; startid=i-3; i--; }
                   break;
          case 13: if(str[i]=='{' || str[i]==NULL)
                   {
                     printf("else : Keyword n");
                     state=0;
                     i--;
                   }
                   else { state=17; startid=i-4; i--; }
                   break;

          //States for 'for'
          case 14: if(str[i]=='o') state=15;
                   else { state=17; startid=i-1; i--; }
                   break;
          case 15: if(str[i]=='r') state=16;
                   else { state=17; startid=i-2; i--; }
                   break;
          case 16: if(str[i]=='(' || str[i]==NULL)
                   {
                     printf("for : Keyword n");
                     state=0;
                     i--;
                   }
                   else { state=17; startid=i-3; i--; }
                   break;

          //States for identifiers
          case 17:

          if(isalnum(str[i]) || str[i]=='_')
          {
                   state=18; i++;
          }
else if(str[i]==NULL||str[i]=='<'||str[i]=='>'||str[i]=='('||str[i]==')'||str[i]==';'||str[i]=='='||str[i]=='+'||
str[i]=='-') state=18;
                    i--;
                    break;

          case 18:

if(str[i]==NULL || str[i]=='<' || str[i]=='>' || str[i]=='(' || str[i]==')' || str[i]==';' || str[i]=='=' || str[i]=='+'
||str[i]=='-')
                  {
                    endid=i-1;
                    printf(" ");
                    for(j=startid; j<=endid; j++)
                          printf("%c", str[j]);
printf("      : Identifier n");
           state=0;
           i--;
         }
         break;

//States for relational operator '<' & '<='
case 19: if(str[i]=='=') state=20;
         else if(isalnum(str[i]) || str[i]=='_')
         {
           printf("<       : Relational operator n");
           i--;
           state=0;
         }
         break;
case 20: if(isalnum(str[i]) || str[i]=='_')
         {
           printf("<= : Relational operator n");
           i--;
           state=0;
         }
         break;

//States for relational operator '>' & '>='
case 21: if(str[i]=='=') state=22;
         else if(isalnum(str[i]) || str[i]=='_')
         {
           printf(">       : Relational operator n");
           i--;
           state=0;
         }
         break;
case 22: if(isalnum(str[i]) || str[i]=='_')
         {
           printf(">= : Relational operator n");
           i--;
           state=0;
         }
         break;

//States for relational operator '==' & assignment operator '='
case 23: if(str[i]=='=') state=24;
         else
         {
           printf("=       : Assignment operator n");
           i--;
           state=0;
         }
break;
          case 24: if(isalnum(str[i]))
                   {
                     printf("== : Relational operator n");
                     state=0;
                     i--;
                   }
                   break;

          //States for constants
          case 25: if(isalpha(str[i]))
                     {
                       printf(" *** ERROR *** n ");
                       puts(str);
                       for(j=0; j<i; j++)
                             printf(" ");
                       printf("^");
                       printf("Error at position %d Alphabet cannot follow digit n", i);
                       state=99;
                     }
else if(str[i]=='(' || str[i]==')' || str[i]=='<' || str[i]=='>' || str[i]==NULL || str[i]==';' || str[i]=='=')
                     {
                       endcon=i-1;
                       printf(" ");
                       for(j=startcon; j<=endcon; j++)
                             printf("%c", str[j]);
                       printf("        : Constant n");
                       state=0;
                       i--;
                     }
                     break;

          //State for special character '('
          case 26: printf(" (      : Special character n");
                   startid=i;
                   state=0;
                   i--;
                   break;

          //State for special character ')'
          case 27: printf(" )      : Special character n");
                   state=0;
                   i--;
                   break;

          //State for special character ';'
          case 28: printf(" ;      : Special character n");
                   state=0;
i--;
                      break;

             //State for operator '+'
             case 29: printf(" +      : Operator n");
                      state=0;
                      i--;
                      break;

             //State for operator '-'
             case 30: printf("+       : Operator n");
                      state=0;
                      i--;
                      break;

             //Error State
             case 99: goto END;
      }
      i++;
    }
    printf("n End of program");
    END:
    getch();
}

/*           Output

Correct input
-------------

*** Program on Lexical Analysis ***


Enter the string: for(x1=0; x1<=10; x1++);


Analysis:

for      : Keyword
(      : Special character
x1       : Identifier
=       : Assignment operator
0       : Constant
;      : Special character
x1       : Identifier
<=       : Relational operator
10       : Constant
;      : Special character
x1 : Identifier
+   : Operator
+   : Operator
)  : Special character
;  : Special character

End of program



Wrong input
-----------

*** Program on Lexical Analysis ***


Enter the string: for(x1=0; x1<=19x; x++);


Analysis:

for     : Keyword
(     : Special character
x1      : Identifier
=      : Assignment operator
0      : Constant
;     : Special character
x1      : Identifier
<=      : Relational operator

Token cannot be generated
*/

OUTPUT
*** Program on Lexical Analysis ***Enter the string: if (a>b) a=25;
Analysis:if : Keyword
 ( : Special character
a : Identifier
>    : Relational operator
b : Identifier
 ) : Special character
a : Identifier
=    : Assignment operator
25 : Constant
 ; : Special character

End of program
/*Count number of characters, words, lines in a file */

#include<fstream.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
void main()
{ clrscr();
char ch,fname[50];
int count=0,ascii,line=0,words=0,previous=10;
cout<<"Enter the complete path of the file:"<<"n";
cin.get(fname,50);
 fstream fio;
 fio.open(fname,ios::in) ;
 fio.seekg(0);
while(fio)
{ fio.get(ch);
 if(ch !=10 && ch !=-1)
{
 count++;
if(ch==32 && previous !=32)
{words++;
}
previous=ch;
}
else
{if(ch==10)
 line++;
if (previous !=10 && previous != 32)
 words++;
previous=ch;
}
ascii=ch;
cout<<ch<<":"<< ascii<<"n";
}

fio.close();
cout<<"number of characters:"<<count<<"n";
cout<<"number of lines:"<<line<<"n";
cout<<"number of words:"<<words<<"n";
getch();
}
OUTPUT
Enter the complete path of the file:
c:Documents and SettingsUser1Desktoptext.txt
number of characters:98
number of lines:4
number of words:26


*/ First and follow */

#include<iostream.h>
#include<conio.h>
struct prod
{ char left, right[10][10];
  int no_prod;
};
struct firstnfollow
{ char ch[100];
  int n_f;
};
void main()
{ clrscr();
  prod p[]={{'E',{"TR"},1},
       {'R',{"+TR","~"},2},
       {'T',{"FD"},1},
        {'D',{"*FD","~"},2},
        {'F',{"(E)","i"},2}};

 firstnfollow f1[10];
 firstnfollow f2[]={{"$",1},{"",0},{"",0},{"",0},{"",0}};
int n=5; // int n=5;
 char temp;
 for(int i=0;i<n;i++)
  { for(int j=0;j<p[i].no_prod;j++)
    { f1[i].ch[j]=p[i].right[j][0];
      f1[i].n_f=p[i].no_prod;
    }
  }
 for(i=0;i<n;i++)
  { while(f1[i].ch[0]>=65&&f1[i].ch[0]<=90)
    { temp=f1[i].ch[0];
      for(int j=1;j<f1[i].n_f;j++)
       f1[i].ch[j-1]=f1[i].ch[j];
      f1[i].n_f--;

     for(int k=0;k<n;k++)
if(temp==p[k].left)
       { for(j=0;j<f1[k].n_f;j++)
          f1[i].ch[f1[i].n_f+j]=f1[k].ch[j];
         f1[i].n_f+=f1[k].n_f;
         break;
       }
  }
 }
int k,flag;
for(i=0;i<n;i++)
 { for(int j=0;j<p[i].no_prod;j++)
   { k=0;
     while(p[i].right[j][k]!='0')
     { if(p[i].right[j][k]>=65&&p[i].right[j][k]<=90&&p[i].right[j][k+1]!='0')
        { for(int x=0;x<n;x++)
           if(p[i].right[j][k]==p[x].left)
            break;
          for(int y=0;y<n;y++)
           if(p[i].right[j][k+1]==p[y].left)
            break;
          if(y<5)
           { for(int s=0;s<f1[y].n_f;s++)
              if(f1[y].ch[s]!='~')
               f2[x].ch[f2[x].n_f++]=f1[y].ch[s];
           }
          else
           f2[x].ch[f2[x].n_f++]=p[i].right[j][k+1];
        }
       k++;
     }
   }
 }
for(i=0;i<n;i++)
 { for(int j=0;j<p[i].no_prod;j++)
   { k=0;
     while(p[i].right[j][k]!='0')
     { if(p[i].right[j][k]>=65&&p[i].right[j][k]<=90)
        { if(p[i].right[j][k+1]=='0')
           { for(int a=0;a<n;a++)
              if(p[i].right[j][k]==p[a].left)
               break;
             if(a!=i)
              for(int b=0;b<f2[i].n_f;b++)
               f2[a].ch[f2[a].n_f++]=f2[i].ch[b];
           }
          else
           { if(p[i].right[j][k+1]>=65&&p[i].right[j][k+1]<=90)
              { flag=0;
for(int x=0;x<n;x++)
                   if(p[i].right[j][k+1]==p[x].left)
                    break;
                  for(int s=0;s<f1[x].n_f;s++)
                   if(f1[x].ch[s]=='~')
                    { flag=1;
                      break;
                    }
                  if(flag==1)
                   { for(int a=0;a<n;a++)
                      if(p[i].right[j][k]==p[a].left)
                       break;
                     for(int b=0;b<f2[i].n_f;b++)
                      f2[a].ch[f2[a].n_f++]=f2[i].ch[b];
                   }
              }
         }
        }
       k++;
      }
  }
 }
int q,j,s;
for(i=0;i<n;i++)
 { q=0;
   j=0;
   while(f2[i].ch[j]!='0')
    { k=j+1;
      while(f2[i].ch[k]!='0')
       { if(f2[i].ch[j]==f2[i].ch[k])
         { s=k;
           while(f2[i].ch[s]!='0')
           { f2[i].ch[s]=f2[i].ch[s+1];
             s++;q++;
           }
         }
         else
          k++;
       }
      j++;
    }
   f2[i].n_f-=q;
 }
cout<<"The Firsts are: ";
for(i=0;i<n;i++)
 { cout<<"n"<<p[i].left<<" ---- ";
   for(int j=0;j<f1[i].n_f;j++)
    cout<<f1[i].ch[j]<<" ";
}
    cout<<"nThe Follows are: ";
    for(i=0;i<n;i++)
     { cout<<"n"<<p[i].left<<" ---- ";
       j=0;
       while(f2[i].ch[j]!='0')
        { cout<<f2[i].ch[j]<<" ";
          j++;
        }
     }
    getch();
}




OUTPUT
The Firsts are:
E ---- ( i
R ---- + ~
T ---- ( i
D ---- * ~
F ---- ( i
The Follows are:
E ---- $ )
R ---- $ )
T ---- + $ )
D ---- + $ )
F ---- * + $ )

More Related Content

What's hot

Session05 iteration structure
Session05 iteration structureSession05 iteration structure
Session05 iteration structure
HarithaRanasinghe
 
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
Lakshmi Sarvani Videla
 
Pointer level 2
Pointer   level 2Pointer   level 2
Pointer level 2
Mohammed Sikander
 
[KOSSA] C++ Programming - 17th Study - STL #3
[KOSSA] C++ Programming - 17th Study - STL #3[KOSSA] C++ Programming - 17th Study - STL #3
[KOSSA] C++ Programming - 17th Study - STL #3
Seok-joon Yun
 
Static and const members
Static and const membersStatic and const members
Static and const members
mohamed sikander
 
Python 炒股指南
Python 炒股指南 Python 炒股指南
Python 炒股指南
Leo Zhou
 
Let us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solutionLet us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solution
rohit kumar
 
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solutionLet us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Hazrat Bilal
 
C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5
Rumman Ansari
 
Numerical Methods in C
Numerical Methods in CNumerical Methods in C
Numerical Methods in C
Ambili Baby
 
simple-movie-ticket-booking-system-1
simple-movie-ticket-booking-system-1simple-movie-ticket-booking-system-1
simple-movie-ticket-booking-system-1
Ajay132002
 
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
rohit kumar
 
Stl algorithm-Basic types
Stl algorithm-Basic typesStl algorithm-Basic types
Stl algorithm-Basic types
mohamed sikander
 
Aplikasi menghitung matematika dengan c++
Aplikasi menghitung matematika dengan c++Aplikasi menghitung matematika dengan c++
Aplikasi menghitung matematika dengan c++
radar radius
 
LET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERSLET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERS
KavyaSharma65
 
Computer Science Practical Science C++ with SQL commands
Computer Science Practical Science C++ with SQL commandsComputer Science Practical Science C++ with SQL commands
Computer Science Practical Science C++ with SQL commands
Vishvjeet Yadav
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
Azhar Javed
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
vrgokila
 
Let us c chapter 4 solution
Let us c chapter 4 solutionLet us c chapter 4 solution
Let us c chapter 4 solution
rohit kumar
 
Let us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solutionLet us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solution
Hazrat Bilal
 

What's hot (20)

Session05 iteration structure
Session05 iteration structureSession05 iteration structure
Session05 iteration structure
 
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
 
Pointer level 2
Pointer   level 2Pointer   level 2
Pointer level 2
 
[KOSSA] C++ Programming - 17th Study - STL #3
[KOSSA] C++ Programming - 17th Study - STL #3[KOSSA] C++ Programming - 17th Study - STL #3
[KOSSA] C++ Programming - 17th Study - STL #3
 
Static and const members
Static and const membersStatic and const members
Static and const members
 
Python 炒股指南
Python 炒股指南 Python 炒股指南
Python 炒股指南
 
Let us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solutionLet us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solution
 
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solutionLet us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
 
C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5
 
Numerical Methods in C
Numerical Methods in CNumerical Methods in C
Numerical Methods in C
 
simple-movie-ticket-booking-system-1
simple-movie-ticket-booking-system-1simple-movie-ticket-booking-system-1
simple-movie-ticket-booking-system-1
 
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
 
Stl algorithm-Basic types
Stl algorithm-Basic typesStl algorithm-Basic types
Stl algorithm-Basic types
 
Aplikasi menghitung matematika dengan c++
Aplikasi menghitung matematika dengan c++Aplikasi menghitung matematika dengan c++
Aplikasi menghitung matematika dengan c++
 
LET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERSLET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERS
 
Computer Science Practical Science C++ with SQL commands
Computer Science Practical Science C++ with SQL commandsComputer Science Practical Science C++ with SQL commands
Computer Science Practical Science C++ with SQL commands
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
 
Let us c chapter 4 solution
Let us c chapter 4 solutionLet us c chapter 4 solution
Let us c chapter 4 solution
 
Let us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solutionLet us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solution
 

Viewers also liked

Drupal Association Supporter Update Q1 2017
Drupal Association Supporter Update Q1 2017Drupal Association Supporter Update Q1 2017
Drupal Association Supporter Update Q1 2017
Docker, Inc
 
Synopsis Seminar Brain Finger Printing
Synopsis Seminar Brain Finger PrintingSynopsis Seminar Brain Finger Printing
Synopsis Seminar Brain Finger PrintingGarima Singh
 
Brain fingerprinting padmaja
Brain fingerprinting padmajaBrain fingerprinting padmaja
Brain fingerprinting padmaja
Padmaja Dash
 
BRAIN FINGERPRINTING
BRAIN FINGERPRINTINGBRAIN FINGERPRINTING
BRAIN FINGERPRINTING
Aurobindo Nayak
 
Brain Fingerprinting PPT
Brain Fingerprinting PPTBrain Fingerprinting PPT
Brain Fingerprinting PPT
Vishnu Mysterio
 
Brain fingerprinting
Brain fingerprintingBrain fingerprinting
Brain fingerprinting
mashuj
 
Designing Teams for Emerging Challenges
Designing Teams for Emerging ChallengesDesigning Teams for Emerging Challenges
Designing Teams for Emerging Challenges
Aaron Irizarry
 

Viewers also liked (8)

Drupal Association Supporter Update Q1 2017
Drupal Association Supporter Update Q1 2017Drupal Association Supporter Update Q1 2017
Drupal Association Supporter Update Q1 2017
 
Synopsis Seminar Brain Finger Printing
Synopsis Seminar Brain Finger PrintingSynopsis Seminar Brain Finger Printing
Synopsis Seminar Brain Finger Printing
 
Brain fingerprinting padmaja
Brain fingerprinting padmajaBrain fingerprinting padmaja
Brain fingerprinting padmaja
 
BRAIN FINGERPRINTING
BRAIN FINGERPRINTINGBRAIN FINGERPRINTING
BRAIN FINGERPRINTING
 
Brain fingerprinting
Brain fingerprintingBrain fingerprinting
Brain fingerprinting
 
Brain Fingerprinting PPT
Brain Fingerprinting PPTBrain Fingerprinting PPT
Brain Fingerprinting PPT
 
Brain fingerprinting
Brain fingerprintingBrain fingerprinting
Brain fingerprinting
 
Designing Teams for Emerging Challenges
Designing Teams for Emerging ChallengesDesigning Teams for Emerging Challenges
Designing Teams for Emerging Challenges
 

Similar to Complier File

VTU Data Structures Lab Manual
VTU Data Structures Lab ManualVTU Data Structures Lab Manual
VTU Data Structures Lab Manual
Nithin Kumar,VVCE, Mysuru
 
MineSweeper.java public class MS { public static void main(Strin.pdf
MineSweeper.java public class MS { public static void main(Strin.pdfMineSweeper.java public class MS { public static void main(Strin.pdf
MineSweeper.java public class MS { public static void main(Strin.pdf
aniyathikitchen
 
Data StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdf
Data StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdfData StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdf
Data StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdf
rozakashif85
 
Hangman Game Programming in C (coding)
Hangman Game Programming in C (coding)Hangman Game Programming in C (coding)
Hangman Game Programming in C (coding)
hasan0812
 
calc3build# calc3bison -y -d calc3.yflex calc3.lgcc -c .docx
calc3build# calc3bison -y -d calc3.yflex calc3.lgcc -c .docxcalc3build# calc3bison -y -d calc3.yflex calc3.lgcc -c .docx
calc3build# calc3bison -y -d calc3.yflex calc3.lgcc -c .docx
RAHUL126667
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop concept
kinan keshkeh
 
CONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.pptCONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.ppt
Sanjjaayyy
 
#include stdio.h#include stdlib.h#include string.h#inclu.pdf
#include stdio.h#include stdlib.h#include string.h#inclu.pdf#include stdio.h#include stdlib.h#include string.h#inclu.pdf
#include stdio.h#include stdlib.h#include string.h#inclu.pdf
apleather
 
import java.util.Scanner;public class Main {    public static in.pdf
import java.util.Scanner;public class Main {    public static in.pdfimport java.util.Scanner;public class Main {    public static in.pdf
import java.util.Scanner;public class Main {    public static in.pdf
anwarsadath111
 
Cpds lab
Cpds labCpds lab
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop concept
kinan keshkeh
 
ANS#include iostream int Rn_get(int low, int high); int cva.pdf
ANS#include iostream int Rn_get(int low, int high); int cva.pdfANS#include iostream int Rn_get(int low, int high); int cva.pdf
ANS#include iostream int Rn_get(int low, int high); int cva.pdf
anikkothari1
 
FINAL PROJECTpacka.docx
FINAL PROJECTpacka.docxFINAL PROJECTpacka.docx
FINAL PROJECTpacka.docx
AKHIL969626
 
#include -stdio-h- #include -stdlib-h- #include -stdbool-h- #include - (1).docx
#include -stdio-h- #include -stdlib-h- #include -stdbool-h- #include - (1).docx#include -stdio-h- #include -stdlib-h- #include -stdbool-h- #include - (1).docx
#include -stdio-h- #include -stdlib-h- #include -stdbool-h- #include - (1).docx
PiersRCoThomsonw
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
Saranya saran
 
Getting the following errorsError 1 error C2436 {ctor} mem.pdf
Getting the following errorsError 1 error C2436 {ctor}  mem.pdfGetting the following errorsError 1 error C2436 {ctor}  mem.pdf
Getting the following errorsError 1 error C2436 {ctor} mem.pdf
herminaherman
 

Similar to Complier File (20)

VTU Data Structures Lab Manual
VTU Data Structures Lab ManualVTU Data Structures Lab Manual
VTU Data Structures Lab Manual
 
MineSweeper.java public class MS { public static void main(Strin.pdf
MineSweeper.java public class MS { public static void main(Strin.pdfMineSweeper.java public class MS { public static void main(Strin.pdf
MineSweeper.java public class MS { public static void main(Strin.pdf
 
Data StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdf
Data StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdfData StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdf
Data StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdf
 
week-18x
week-18xweek-18x
week-18x
 
week-17x
week-17xweek-17x
week-17x
 
Hangman Game Programming in C (coding)
Hangman Game Programming in C (coding)Hangman Game Programming in C (coding)
Hangman Game Programming in C (coding)
 
week-16x
week-16xweek-16x
week-16x
 
calc3build# calc3bison -y -d calc3.yflex calc3.lgcc -c .docx
calc3build# calc3bison -y -d calc3.yflex calc3.lgcc -c .docxcalc3build# calc3bison -y -d calc3.yflex calc3.lgcc -c .docx
calc3build# calc3bison -y -d calc3.yflex calc3.lgcc -c .docx
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop concept
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
 
CONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.pptCONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.ppt
 
#include stdio.h#include stdlib.h#include string.h#inclu.pdf
#include stdio.h#include stdlib.h#include string.h#inclu.pdf#include stdio.h#include stdlib.h#include string.h#inclu.pdf
#include stdio.h#include stdlib.h#include string.h#inclu.pdf
 
import java.util.Scanner;public class Main {    public static in.pdf
import java.util.Scanner;public class Main {    public static in.pdfimport java.util.Scanner;public class Main {    public static in.pdf
import java.util.Scanner;public class Main {    public static in.pdf
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop concept
 
ANS#include iostream int Rn_get(int low, int high); int cva.pdf
ANS#include iostream int Rn_get(int low, int high); int cva.pdfANS#include iostream int Rn_get(int low, int high); int cva.pdf
ANS#include iostream int Rn_get(int low, int high); int cva.pdf
 
FINAL PROJECTpacka.docx
FINAL PROJECTpacka.docxFINAL PROJECTpacka.docx
FINAL PROJECTpacka.docx
 
#include -stdio-h- #include -stdlib-h- #include -stdbool-h- #include - (1).docx
#include -stdio-h- #include -stdlib-h- #include -stdbool-h- #include - (1).docx#include -stdio-h- #include -stdlib-h- #include -stdbool-h- #include - (1).docx
#include -stdio-h- #include -stdlib-h- #include -stdbool-h- #include - (1).docx
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 
Getting the following errorsError 1 error C2436 {ctor} mem.pdf
Getting the following errorsError 1 error C2436 {ctor}  mem.pdfGetting the following errorsError 1 error C2436 {ctor}  mem.pdf
Getting the following errorsError 1 error C2436 {ctor} mem.pdf
 

More from Garima Singh

SlideShare Team
SlideShare TeamSlideShare Team
SlideShare Team
Garima Singh
 
Acn Experiment No 5
Acn Experiment No 5Acn Experiment No 5
Acn Experiment No 5
Garima Singh
 
Acn Experiment No 2
Acn Experiment No 2Acn Experiment No 2
Acn Experiment No 2
Garima Singh
 
Acn Experiment No 4
Acn Experiment No 4Acn Experiment No 4
Acn Experiment No 4
Garima Singh
 
Acn Experiment No 3
Acn Experiment No 3Acn Experiment No 3
Acn Experiment No 3
Garima Singh
 
Acn Experiment No 6
Acn Experiment No 6Acn Experiment No 6
Acn Experiment No 6
Garima Singh
 
Brain Finger Printing
Brain Finger PrintingBrain Finger Printing
Brain Finger PrintingGarima Singh
 
Brain Finger Printing
Brain Finger PrintingBrain Finger Printing
Brain Finger PrintingGarima Singh
 
Modified Rabin Karp
Modified Rabin KarpModified Rabin Karp
Modified Rabin Karp
Garima Singh
 
Data Mining
Data MiningData Mining
Data Mining
Garima Singh
 

More from Garima Singh (12)

Animations
AnimationsAnimations
Animations
 
Animations
AnimationsAnimations
Animations
 
SlideShare Team
SlideShare TeamSlideShare Team
SlideShare Team
 
Acn Experiment No 5
Acn Experiment No 5Acn Experiment No 5
Acn Experiment No 5
 
Acn Experiment No 2
Acn Experiment No 2Acn Experiment No 2
Acn Experiment No 2
 
Acn Experiment No 4
Acn Experiment No 4Acn Experiment No 4
Acn Experiment No 4
 
Acn Experiment No 3
Acn Experiment No 3Acn Experiment No 3
Acn Experiment No 3
 
Acn Experiment No 6
Acn Experiment No 6Acn Experiment No 6
Acn Experiment No 6
 
Brain Finger Printing
Brain Finger PrintingBrain Finger Printing
Brain Finger Printing
 
Brain Finger Printing
Brain Finger PrintingBrain Finger Printing
Brain Finger Printing
 
Modified Rabin Karp
Modified Rabin KarpModified Rabin Karp
Modified Rabin Karp
 
Data Mining
Data MiningData Mining
Data Mining
 

Recently uploaded

BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 

Recently uploaded (20)

BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 

Complier File

  • 1. COMPLIER FILE Submitted by: Pinak Mukherjee (038/CS/GTBIT/04) Department of Computer Science and Engineering Guru Tegh Bahadur Institute of Technology
  • 2. /*Generation of code in c++ to add two numbers by coding in c*/ void main() {char a[40],b[40],c[40],d[40]; clrscr(); do {printf("Enter class name=>"); scanf("%s",a); }while(strlen(a)>=40); do {printf("Enter name of first variable=>"); scanf("%s",b); }while((!strcmp(a,b))||(strlen(b)>=40)); do {printf("Enter name of second variable=>"); scanf("%s",c); }while((!strcmp(a,c))||(!strcmp(c,b))||(strlen(c)>=40)); do {printf("Enter name of class variable=>"); scanf("%s",d); }while((!strcmp(a,d))||(!strcmp(d,c))||(!strcmp(d,b))||(strlen(d)>=40)); clrscr(); printf("class %s",a); printf("n{n private:n"); printf(" int %s;n",b); printf(" int %s;n",c); printf(" public:n"); printf(" void getinput()n {"); printf("n cout<<"Enter first number:";"); printf("n cin>>%s;",b); printf("n cout<<"Enter second number:";"); printf("n cin>>%s;",c); printf("n }"); printf("n void addnos()n {"); printf("n cout<<"The Sum is:"<<%s+%s;",b,c); printf("n }"); printf("n };"); printf("nvoid main()n {"); printf("n %s %s;",a,d); printf("n %s.getinput();",d); printf("n %s.addnos();",d); printf("n }"); getch(); }
  • 3. OUTPUT Enter class name=>student Enter name of first variable=>a Enter name of second variable=>b Enter name of class variable=>student1 class student { private: int a; int b; public: void getinput() { cout<<"Enter first number:"; cin>>a; cout<<"Enter second number:"; cin>>b; } void addnos() { cout<<"The Sum is:"<<a+b; } }; void main() { student student1; student1.getinput(); student1.addnos(); }
  • 4. /*Generation of code in java through code in c*/ void main() {char a[40],b[40],c[40],d[40]; clrscr(); do {printf("Enter class name=>"); scanf("%s",a); }while(strlen(a)>=40); do {printf("Enter name of first variable=>"); scanf("%s",b); }while((!strcmp(a,b))||(strlen(b)>=40)); do {printf("Enter name of second variable=>"); scanf("%s",c); }while((!strcmp(a,c))||(!strcmp(c,b))||(strlen(c)>=40)); do {printf("Enter name of class variable=>"); scanf("%s",d); }while((!strcmp(a,d))||(!strcmp(d,c))||(!strcmp(d,b))||(strlen(d)>=40)); clrscr(); printf("public class %s",a); printf("private int %s;n",b); printf("private int %s;n",c); printf("public static void main(){n"); printf("n System.out.println("Enter first number:");"); printf("n cin>>%s;",b); printf("n System.out.println("Enter second number:");"); printf("n cin>>%s;",c); printf("n System.out.println("The Sum is:",%s+%s);",b,c); printf("n }"); printf("n}"); getch(); } OUTPUT
  • 5. Enter class name=>STUDENT Enter name of first variable=>A Enter name of second variable=>B Enter name of class variable=>STUDENT1 public class STUDENTprivate int A; private int B; public static void main(){ System.out.println("Enter first number:"); cin>>A; System.out.println("Enter second number:"); cin>>B; System.out.println("The Sum is:",A+B); } } /* Program on lexical analysis */ #include"stdio.h" #include"conio.h" #include"string.h" #include"ctype.h" #define MAX 30 void main() { char str[MAX]; int state=0; int i=0, j, startid=0, endid, startcon, endcon; clrscr(); for(j=0; j<MAX; j++) str[j]=NULL; //Initialise NULL printf("*** Program on Lexical Analysis ***"); printf("Enter the string: "); gets(str); //Accept input string str[strlen(str)]=' '; printf("Analysis:"); while(str[i]!=NULL) { while(str[i]==' ') //To eliminate spaces i++; switch(state) { case 0: if(str[i]=='i') state=1; //if else if(str[i]=='w') state=3; //while
  • 6. else if(str[i]=='d') state=8; //do else if(str[i]=='e') state=10; //else else if(str[i]=='f') state=14; //for else if(isalpha(str[i]) || str[i]=='_') { state=17; startid=i; } //identifiers else if(str[i]=='<') state=19; //relational '<' or '<=' else if(str[i]=='>') state=21; //relational '>' or '>=' else if(str[i]=='=') state=23; //relational '==' or assignment '=' else if(isdigit(str[i])) { state=25; startcon=i; } //constant else if(str[i]=='(') state=26; //special characters '(' else if(str[i]==')') state=27; //special characters ')' else if(str[i]==';') state=28; //special characters ';' else if(str[i]=='+') state=29; //operator '+' else if(str[i]=='-') state=30; //operator '-' break; //States for 'if' case 1: if(str[i]=='f') state=2; else { state=17; startid=i-1; i--; } break; case 2: if(str[i]=='(' || str[i]==NULL) { printf("if : Keywordn");
  • 7. state=0; i--; } else { state=17; startid=i-2; i--; } break; //States for 'while' case 3: if(str[i]=='h') state=4; else { state=17; startid=i-1; i--; } break; case 4: if(str[i]=='i') state=5; else { state=17; startid=i-2; i--; } break; case 5: if(str[i]=='l') state=6; else { state=17; startid=i-3; i--; } break; case 6: if(str[i]=='e') state=7; else { state=17; startid=i-4; i--; } break; case 7: if(str[i]=='(' || str[i]==NULL) { printf("while : Keyword n"); state=0; i--; } else { state=17; startid=i-5; i--; } break; //States for 'do' case 8: if(str[i]=='o') state=9; else { state=17; startid=i-1; i--; } break; case 9: if(str[i]=='{' || str[i]==' ' || str[i]==NULL || str[i]=='(') { printf("do : Keyword n"); state=0; i--; } break; //States for 'else' case 10: if(str[i]=='l') state=11; else { state=17; startid=i-1; i--; } break; case 11: if(str[i]=='s') state=12; else { state=17; startid=i-2; i--; } break; case 12: if(str[i]=='e') state=13;
  • 8. else { state=17; startid=i-3; i--; } break; case 13: if(str[i]=='{' || str[i]==NULL) { printf("else : Keyword n"); state=0; i--; } else { state=17; startid=i-4; i--; } break; //States for 'for' case 14: if(str[i]=='o') state=15; else { state=17; startid=i-1; i--; } break; case 15: if(str[i]=='r') state=16; else { state=17; startid=i-2; i--; } break; case 16: if(str[i]=='(' || str[i]==NULL) { printf("for : Keyword n"); state=0; i--; } else { state=17; startid=i-3; i--; } break; //States for identifiers case 17: if(isalnum(str[i]) || str[i]=='_') { state=18; i++; } else if(str[i]==NULL||str[i]=='<'||str[i]=='>'||str[i]=='('||str[i]==')'||str[i]==';'||str[i]=='='||str[i]=='+'|| str[i]=='-') state=18; i--; break; case 18: if(str[i]==NULL || str[i]=='<' || str[i]=='>' || str[i]=='(' || str[i]==')' || str[i]==';' || str[i]=='=' || str[i]=='+' ||str[i]=='-') { endid=i-1; printf(" "); for(j=startid; j<=endid; j++) printf("%c", str[j]);
  • 9. printf(" : Identifier n"); state=0; i--; } break; //States for relational operator '<' & '<=' case 19: if(str[i]=='=') state=20; else if(isalnum(str[i]) || str[i]=='_') { printf("< : Relational operator n"); i--; state=0; } break; case 20: if(isalnum(str[i]) || str[i]=='_') { printf("<= : Relational operator n"); i--; state=0; } break; //States for relational operator '>' & '>=' case 21: if(str[i]=='=') state=22; else if(isalnum(str[i]) || str[i]=='_') { printf("> : Relational operator n"); i--; state=0; } break; case 22: if(isalnum(str[i]) || str[i]=='_') { printf(">= : Relational operator n"); i--; state=0; } break; //States for relational operator '==' & assignment operator '=' case 23: if(str[i]=='=') state=24; else { printf("= : Assignment operator n"); i--; state=0; }
  • 10. break; case 24: if(isalnum(str[i])) { printf("== : Relational operator n"); state=0; i--; } break; //States for constants case 25: if(isalpha(str[i])) { printf(" *** ERROR *** n "); puts(str); for(j=0; j<i; j++) printf(" "); printf("^"); printf("Error at position %d Alphabet cannot follow digit n", i); state=99; } else if(str[i]=='(' || str[i]==')' || str[i]=='<' || str[i]=='>' || str[i]==NULL || str[i]==';' || str[i]=='=') { endcon=i-1; printf(" "); for(j=startcon; j<=endcon; j++) printf("%c", str[j]); printf(" : Constant n"); state=0; i--; } break; //State for special character '(' case 26: printf(" ( : Special character n"); startid=i; state=0; i--; break; //State for special character ')' case 27: printf(" ) : Special character n"); state=0; i--; break; //State for special character ';' case 28: printf(" ; : Special character n"); state=0;
  • 11. i--; break; //State for operator '+' case 29: printf(" + : Operator n"); state=0; i--; break; //State for operator '-' case 30: printf("+ : Operator n"); state=0; i--; break; //Error State case 99: goto END; } i++; } printf("n End of program"); END: getch(); } /* Output Correct input ------------- *** Program on Lexical Analysis *** Enter the string: for(x1=0; x1<=10; x1++); Analysis: for : Keyword ( : Special character x1 : Identifier = : Assignment operator 0 : Constant ; : Special character x1 : Identifier <= : Relational operator 10 : Constant ; : Special character
  • 12. x1 : Identifier + : Operator + : Operator ) : Special character ; : Special character End of program Wrong input ----------- *** Program on Lexical Analysis *** Enter the string: for(x1=0; x1<=19x; x++); Analysis: for : Keyword ( : Special character x1 : Identifier = : Assignment operator 0 : Constant ; : Special character x1 : Identifier <= : Relational operator Token cannot be generated */ OUTPUT *** Program on Lexical Analysis ***Enter the string: if (a>b) a=25; Analysis:if : Keyword ( : Special character a : Identifier > : Relational operator b : Identifier ) : Special character a : Identifier = : Assignment operator 25 : Constant ; : Special character End of program
  • 13. /*Count number of characters, words, lines in a file */ #include<fstream.h> #include<conio.h> #include<string.h> #include<ctype.h> void main() { clrscr(); char ch,fname[50]; int count=0,ascii,line=0,words=0,previous=10; cout<<"Enter the complete path of the file:"<<"n"; cin.get(fname,50); fstream fio; fio.open(fname,ios::in) ; fio.seekg(0); while(fio) { fio.get(ch); if(ch !=10 && ch !=-1) { count++; if(ch==32 && previous !=32) {words++; } previous=ch; } else {if(ch==10) line++; if (previous !=10 && previous != 32) words++; previous=ch; } ascii=ch; cout<<ch<<":"<< ascii<<"n"; } fio.close(); cout<<"number of characters:"<<count<<"n"; cout<<"number of lines:"<<line<<"n"; cout<<"number of words:"<<words<<"n"; getch();
  • 14. } OUTPUT Enter the complete path of the file: c:Documents and SettingsUser1Desktoptext.txt number of characters:98 number of lines:4 number of words:26 */ First and follow */ #include<iostream.h> #include<conio.h> struct prod { char left, right[10][10]; int no_prod; }; struct firstnfollow { char ch[100]; int n_f; }; void main() { clrscr(); prod p[]={{'E',{"TR"},1}, {'R',{"+TR","~"},2}, {'T',{"FD"},1}, {'D',{"*FD","~"},2}, {'F',{"(E)","i"},2}}; firstnfollow f1[10]; firstnfollow f2[]={{"$",1},{"",0},{"",0},{"",0},{"",0}}; int n=5; // int n=5; char temp; for(int i=0;i<n;i++) { for(int j=0;j<p[i].no_prod;j++) { f1[i].ch[j]=p[i].right[j][0]; f1[i].n_f=p[i].no_prod; } } for(i=0;i<n;i++) { while(f1[i].ch[0]>=65&&f1[i].ch[0]<=90) { temp=f1[i].ch[0]; for(int j=1;j<f1[i].n_f;j++) f1[i].ch[j-1]=f1[i].ch[j]; f1[i].n_f--; for(int k=0;k<n;k++)
  • 15. if(temp==p[k].left) { for(j=0;j<f1[k].n_f;j++) f1[i].ch[f1[i].n_f+j]=f1[k].ch[j]; f1[i].n_f+=f1[k].n_f; break; } } } int k,flag; for(i=0;i<n;i++) { for(int j=0;j<p[i].no_prod;j++) { k=0; while(p[i].right[j][k]!='0') { if(p[i].right[j][k]>=65&&p[i].right[j][k]<=90&&p[i].right[j][k+1]!='0') { for(int x=0;x<n;x++) if(p[i].right[j][k]==p[x].left) break; for(int y=0;y<n;y++) if(p[i].right[j][k+1]==p[y].left) break; if(y<5) { for(int s=0;s<f1[y].n_f;s++) if(f1[y].ch[s]!='~') f2[x].ch[f2[x].n_f++]=f1[y].ch[s]; } else f2[x].ch[f2[x].n_f++]=p[i].right[j][k+1]; } k++; } } } for(i=0;i<n;i++) { for(int j=0;j<p[i].no_prod;j++) { k=0; while(p[i].right[j][k]!='0') { if(p[i].right[j][k]>=65&&p[i].right[j][k]<=90) { if(p[i].right[j][k+1]=='0') { for(int a=0;a<n;a++) if(p[i].right[j][k]==p[a].left) break; if(a!=i) for(int b=0;b<f2[i].n_f;b++) f2[a].ch[f2[a].n_f++]=f2[i].ch[b]; } else { if(p[i].right[j][k+1]>=65&&p[i].right[j][k+1]<=90) { flag=0;
  • 16. for(int x=0;x<n;x++) if(p[i].right[j][k+1]==p[x].left) break; for(int s=0;s<f1[x].n_f;s++) if(f1[x].ch[s]=='~') { flag=1; break; } if(flag==1) { for(int a=0;a<n;a++) if(p[i].right[j][k]==p[a].left) break; for(int b=0;b<f2[i].n_f;b++) f2[a].ch[f2[a].n_f++]=f2[i].ch[b]; } } } } k++; } } } int q,j,s; for(i=0;i<n;i++) { q=0; j=0; while(f2[i].ch[j]!='0') { k=j+1; while(f2[i].ch[k]!='0') { if(f2[i].ch[j]==f2[i].ch[k]) { s=k; while(f2[i].ch[s]!='0') { f2[i].ch[s]=f2[i].ch[s+1]; s++;q++; } } else k++; } j++; } f2[i].n_f-=q; } cout<<"The Firsts are: "; for(i=0;i<n;i++) { cout<<"n"<<p[i].left<<" ---- "; for(int j=0;j<f1[i].n_f;j++) cout<<f1[i].ch[j]<<" ";
  • 17. } cout<<"nThe Follows are: "; for(i=0;i<n;i++) { cout<<"n"<<p[i].left<<" ---- "; j=0; while(f2[i].ch[j]!='0') { cout<<f2[i].ch[j]<<" "; j++; } } getch(); } OUTPUT The Firsts are: E ---- ( i R ---- + ~ T ---- ( i D ---- * ~ F ---- ( i The Follows are: E ---- $ ) R ---- $ ) T ---- + $ ) D ---- + $ ) F ---- * + $ )