Archive for Educational

Top Ten Interview Tips

// February 4th, 2010 // Comments // Educational

Great interviews arise from careful groundwork. You can ace your next interview if you:

interviewTips
1.    Enter into a state of relaxed concentration. This is the state from which great basketball players or Olympic skaters operate. You’ll need to quiet the negative self chatter in your head through meditation or visualization prior to sitting down in the meeting. You’ll focus on the present moment and will be less apt to experience lapses in concentration, nervousness, self-doubt and self-condemnation.

2.    Act spontaneous, but be well prepared. Be your authentic self, professional yet real. Engage in true conversation with your interviewer, resting on the preparation you did prior to coming to the meeting. Conduct several trial runs with another person simulating the interview before it actually occurs. It’s the same as anticipating the questions you’ll be asked on a final exam.

3.    Set goals for the interview. It is your job to leave the meeting feeling secure that the interviewer knows as much as he or she possibly can about your skills, abilities, experience and achievements. If you sense there are misconceptions, clear them up before leaving. If the interviewer doesn’t get around to asking you important questions, pose them yourself (diplomatically) and answer them. Don’t leave the meeting without getting your own questions answered so that you have a clear idea of what you would be getting yourself into. If possible, try to get further interviews, especially with other key players.

4.    Know the question behind the question. Ultimately, every question boils down to, “Why should we hire you?” Be sure you answer that completely. If there is a question about your meeting deadlines, consider whether the interviewer is probing delicately about your personal life, careful not to ask you whether your family responsibilities will interfere with your work. Find away to address fears if you sense they are present.

5.    Follow up with an effective “thank you” letter. Don’t write this letter lightly. It is another opportunity to market yourself. Find some areas discussed in the meeting and expand upon them in your letter. Writing a letter after a meeting is a very minimum. Standing out among the other candidates will occur if you thoughtfully consider this follow up letter as an additional interview in which you get to do all the talking. Propose useful ideas that demonstrate your added value to the team.

6.    Consider the interviewer’s agenda. Much is on the shoulders of the interviewer. He or she has the responsibility of hiring the right candidate. Your ability to do the job will need to be justified. “Are there additional pluses here?” “Will this person fit the culture of this organization?” These as well as other questions will be heavily on the interviewer’s mind. Find ways to demonstrate your qualities above and beyond just doing the job.
7.    Expect to answer the question, “Tell me about yourself.” This is a pet question of prepared and even unprepared interviewers. Everything you include should answer the question, “Why should we hire you?” Carefully prepare your answer to include examples of achievements from your work life that closely match the elements of the job before you. Obviously, you’ll want to know as much about the job description as you can before you respond to the question.

8.    Watch those nonverbal clues. Experts estimate that words express only 30% to 35% of what people actually communicate; facial expressions and body movements and actions convey the rest. Make and keep eye contact. Walk and sit with a confident air. Lean toward an interviewer to show interest and enthusiasm. Speak with a well-modulated voice that supports appropriate excitement for the opportunity before you.

9.    Be smart about money questions. Don’t fall into the trap of telling the interviewer your financial expectations. You may be asking for too little or too much money and in each case ruin your chances of being offered the job. Instead, ask what salary range the job falls in. Attempt to postpone a money discussion until you have a better understanding of the scope of responsibilities of the job.

10.    Don’t hang out your dirty laundry. Be careful not to bare your soul and tell tales that are inappropriate or beyond the scope of the interview. State your previous experience in the most positive terms. Even if you disagreed with a former employer, express your enthusiasm for earlier situations as much as you can. Whenever you speak negatively about another person or situation in which you were directly involved, you run the risk (early in the relationship) of appearing like a troubled person who may have difficulty working with others.

CAT 2010

// December 16th, 2009 // Comments // Educational

image

image

As you all know the CAT went online this year and it has been quite a ride… Below are possible changes that you can expect in 2010 as a result of this years learning’s….

1. IIM-Prometric tie up has been terminated. Applications are invited for new test partners. As of now the top contender seems to be PVR Cinemas who claims to handle more traffic in a day than the IIM does during the entire season. PVR CEO Mr Bijili in a statement said that PVR is the right choice for the CAT given their “expertise” in the Online system. The students will now be able to order pop corn as they take their CAT.

2. In case your servers crash.. Don’t panic.. The popular “Orkut” message will now be replaced with – “YES – Both Donuts and Pepsi for you”

3. Sharad Pawar has been made Managing Director of the IIMs with immediate effect. Lalit Modi will be his deputy and together they plan to make CAT 2010 a bigger success than the IPL. The CAT will now follow a standard 20-20 pattern with power plays and refreshment breaks…

4. Our very own favorite Dr Vijay Mallya has announced the start of his yet un named MBA Training institute. Katrina Kaif will be the brand ambassador for this venture and if rumors are to be believed Yana Gupta will take classes on shapes, curves and figures….

5. Mallya Sir also plans to bring back to India, all previous years CAT question papers that Prometric had stolen and planned to auction in various 3rd World countries like Azerbaijan and Bosnia and Herzegovina.

6. IIM has come out with a press statement rubbishing reports that the servers crash was due to over load or a virus attack for that matter. IIMs have a strong reason to suspect an ISI involvement in this daring attack on the future of every Indian student and there might have even been some funding by the Chinese.

7. Next years CAT might very well be conducted in Kabul under the protection of the Taliban. All those who return home are promised an IIM seat.

8. Director of one of the Symbiosis Institutes (Symbi Inst of Mis Communication SIMC) has come out telling that CAT is all rubbish and that SNAP is the most competitive exam in the country. This has infuriated the director of Lovely Professional University who claims no one can match their selection process.

9. Symbiosis Group of Institutes to be very soon renamed Symbiosis Group of Companies. Plan to buy a few more hills lakes villages and slums and turn them into – “Education Destinations”

10. Deadline for SNAP 2009 has been extended for the 8th time this year. A note on the site says (yes you know it) Too many applicants so the servers are busy. At this rate SNAP will possibly have problems of seating suring the exam. The last date is 31 Dec 2009 now. The exam will be conducted on Dec 20th.

Credits : Samarth [http://www.fakingnews.com/2009/11/cat-servers-hacked-students-asked-extremely-personal-questions/]

System Software Lab Programs ( Lex and Yaac Programs ) 6a

// June 14th, 2009 // Comments // Educational, Engineering, Unix and System Software Lab

Subject : System Software Laboratory

Branch : Information Science & Engineering

Semester : 6

University : VTU

………………………………………………………………………………………………………………………….
PART – A

………………………………………………………………………………………………………………………….

6) Program to recognize the grammar (anb, n>= 10).

6.l

/* 6.l */
%{
#include<stdio.h>
#include “y.tab.h”
%}
%%
[aA] return A;
[bB] return B;
.|n return yytext[0];
%%

—————————————–

6.y

/* 6.y */
%{
#include<stdio.h>
%}
%token A B
%%
stmt: S ‘n’ {printf(“nValid expression”);exit(1);}
;
S: X B
X: X A | A A A A A A A A A A
%%
main()
{
printf(“nEnter the expression: “);
if(yyparse())
{
printf(“nValid expression”);
exit(0);
}
}
int yyerror()
{
printf(“nInvalid expressionn”);
return 1;
}

int yywrap()
{
return 1;
}

File Structure ( FS ) Lab Program 6 ( 6th Semester Information Science) – Alternative 2

// June 13th, 2009 // Comments // Educational, Engineering, File Structure (F.S.) Lab

Program 6 : Write a C++ program to implement index on secondary key, the name, for a file of student objects. Implement add ( ), search ( ), delete ( ) using the secondary index

This includes tow files

1.

//scindex.h
class SCIndex
{
public:

int  Insert (const char  *skey,const char  *pkey);
int  Remove (const char * key);
int Search (const char * key) const;
void Print (ostream &);
void Write (ostream &);
void Read(istream &);
void Init (int maxKeys);
private:
int MaxKeys;
int NumKeys;
char  **sKeys;
char  **pKeys;
int Find (const char * key) const;

};

int SCIndex :: Insert (const char *skey,const char *pkey)
{
int i=0,j=0;
if (NumKeys == MaxKeys) return 0; //no room for another key

for (i = NumKeys-1; i >=0; i–)
{

if(strcmp(skey,sKeys[i]) > 0)
break; // insert into location i+1
else if(strcmp(skey,sKeys[i]) == 0)
break; // insert into location i+1

else
{
sKeys[i+1] = sKeys[i];
pKeys[i+1] = pKeys[i];
}
}
j=i;

for(j=i; j>=0; j–)

//   while(strcmp(skey,sKeys[j]) == 0)
{
if(strcmp(pkey,pKeys[j]) > 0)
break;
sKeys[j+1] = sKeys[j];
pKeys[j+1] = pKeys[j];

}
sKeys[j+1] = strdup(skey);
pKeys[j+1] = strdup(pkey);
NumKeys ++;
return 1;
}

void SCIndex::Write(ostream &stream)
{    int i=0;
stream<<NumKeys<<”|”;
for (i = 0; i <NumKeys; i++)
{

stream<<sKeys[i];
stream<<”|”;
stream<<pKeys[i];
stream<<”|”;

}
}

int SCIndex :: Remove (const char * key)
{
int index = Find (key);
if (index < 0) return 0; // key not in index
for (int i = index; i < NumKeys; i++)
{
sKeys[i] = sKeys[i+1];
pKeys[i] = pKeys[i+1];
}
NumKeys –;
return 1;
}

int  SCIndex :: Search (const char * key) const
{
int i=0,fnd=0;
for(i=0;i<NumKeys;i++)
{
if (strcmp(sKeys[i], key)==0)
{
fnd=1;
cout<<endl<<sKeys[i]<<”             “<<pKeys[i];
}
}
if (fnd==0)
return -1;
return 1;

}

void SCIndex :: Print (ostream & stream)
{
stream << “Secondary Index :  Max keys = “<<MaxKeys
<<”    Number of  keys = “<<NumKeys<<endl;
for (int i = 0; i<NumKeys; i++)
stream <<”tKey["<<i<<"] “<<sKeys[i]
<<”  : Primary key =”<<pKeys[i]<<endl;
}

int SCIndex :: Find (const char * key) const
{
for (int i = 0; i < NumKeys; i++)
if (strcmp(sKeys[i], key)==0)
return i;// key found
else if (strcmp(sKeys[i], key)>0) return -1;// not found
return -1;// not found
}

void SCIndex :: Init (int maxKeys)
{

if (maxKeys <= 0)
{
MaxKeys = 0;
cout<<endl<<”No Records : “<<endl;
}
MaxKeys = maxKeys;
sKeys =new char *[maxKeys];
pKeys = new char *[maxKeys];
NumKeys=0;

}

void SCIndex::Read(istream &stream)
{
int i=0;
/*
stream.read(NumKeys,4);
for (i = 0; i <NumKeys; i++)
{

stream.read(sKeys[i],10);
stream.read(pKeys[i],10);
}
*/
}

—————————————————————————————————————–

2. //lab6.cpp

#include <iostream.h>
#include <fstream.h>
#include <string.h>
#include “student.h”
#include “varbuf.h”
#include “index.h”
#include “scindex.h”

main()
{

//char buffer[500];

student s;
VariableLengthBuffer b;
TextIndex ind;
SCIndex scind;
fstream datafile,indexp,indexs;
int choice=0,k=0,k1=0,n=0;
int recaddr,i;
char delkey[20],skey[20],srchp[10];
datafile.open(“student.txt”,ios::out|ios::in);
indexp.open(“pstudent.ind”, ios::out);
indexs.open(“sstudent.ind”, ios::out);

b.Init(65);
ind.Init(50);
scind.Init(50);
b.Clear();
cout<<endl<<”Enter number of students : “;
cin>>n;

for(i=1;i<=n;i++)
{
cout<<endl<<” Record : “<<i;
s.clear();
s.readdata();
b.Clear();
b.Pack(s.usn);
b.Pack(s.name);
b.Pack(s.address);
b.Pack(s.sem);
recaddr=datafile.tellg();
k=ind.Insert(s.usn,recaddr);
if( k != 1)
cout<<endl<<” Duplicate Primary key : Record Not Inserted “;
else
{
b.Write(datafile);
k=scind.Insert(s.name,s.usn);
}
}

do
{
cout<<endl;
cout<<endl<<”1.Insert Record “;
cout<<endl<<”2.Delete Record “;
cout<<endl<<”3.Search Record “;
cout<<endl<<”4.Display Primary Index”;
cout<<endl<<”5.Display Secondary Index”;
cout<<endl<<”6.Exit “;
cout<<endl;

cout<<” Enter your choice “;
cin>>choice;
switch(choice)
{
case 1:
cout<<endl;
s.readdata();
datafile.seekg(0,ios::end);
recaddr=datafile.tellg();
k=ind.Insert(s.usn,recaddr);
if(k!=1)
cout<<endl<<”Record not inserted : Duplicate Primary Key “;

else
{
k=scind.Insert(s.name,s.usn);
b.Clear();
b.Pack(s.usn);
b.Pack(s.name);
b.Pack(s.address);
b.Pack(s.sem);
b.Write(datafile);
cout<<endl<<”Record Inserted “;
}
break;

case 2:
cout<<endl;
cout<<” Enter Name of the Record to be deleted : ” ;
cin>>delkey;
cout<<endl<<”Following Record/s Found for : “<<delkey<<endl;
cout<<endl<<”Secondary Key   Primary Key”;
cout<<endl<<”————–  ————-”;
k1=scind.Search(delkey);
if(k1 !=1)
{
cout<<endl<<” Record not found “;
break;
}
else
{
cout<<endl<<” Enter USN : “;
cin>>srchp;

k=scind.Remove(delkey);
k1=ind.Remove(srchp);
if(k!=1 || k1!=1)
cout<<endl<<”Record not Found “;
else
cout<<endl<<”Record of “<<delkey<<” USN “<<srchp<<” Deleted”;

}
break;

case 3:
cout<<endl;
cout<<” Enter name of the student to be Searched : ” ;
cin>>skey;
cout<<endl<<”Following Record/s Found for : “<<skey<<endl;
cout<<endl<<”Secondary Key    Primary Key”;
cout<<endl<<”————–   ————”;

k1=scind.Search(skey);
if(k1 !=1)
{
cout<<endl<<” Record not found “;
break;
}
else
{
cout<<endl<<” Enter USN : “;
cin>>srchp;
recaddr=ind.Search(srchp);
if(recaddr<0)
cout<<endl<<”Record does not exist”;
else
{
cout<<endl<<” Record found “;
cout<<endl<<”Record reference of USN “<<srchp<<” is “<<recaddr<<endl;
datafile.seekg(recaddr,ios::beg);
b.Clear();
b.Read(datafile);
b.bufdisplay();
s.clear();
b.Unpack(s.usn);
b.Unpack(s.name);
b.Unpack(s.address);
b.Unpack(s.sem);
s.display();
s.clear();
datafile.seekg(0,ios::end);
}
}
break;

case 4:
ind.Print(cout);
break;

case 5:
scind.Print(cout);
break;
//case 5: exit(1);
}
}   while(choice < 6);

ind.Write(indexp);
scind.Write(indexs);

indexp.close();
indexs.close();
datafile.close();

}

File Structure ( FS ) Lab Program 6 ( 6th Semester Information Science)- Alternative 1

// June 13th, 2009 // Comments // Educational, Engineering, File Structure (F.S.) Lab

Program 6 : Write a C++ program to implement index on secondary key, the name, for a file of student objects. Implement add ( ), search ( ), delete ( ) using the secondary index

#include<iostream>
#include<fstream>
#include<sstream>
#include<string>
using namespace std;
class secondary_index{

public:
string Name_list[100];
int Address_list[100];
int count;
void create_index();
void insert() ;
void remove(string);
void delete_from_file(int);
void search(string);
int search_index(string);
void read_from_file(int);
string extract_Name(string);
void sort_index();

};

void secondary_index::create_index()
{
fstream file;
int pos;
string buffer,name;
count=-1;
file.open(“1.txt”,ios::in);
while(!file.eof())
{
pos=file.tellg();
buffer.erase();
getline(file,buffer);
if(buffer.empty())
break;
//imp since it leads the last n and goes to new line
name=extract_Name(buffer);
Name_list[++count]=name;
Address_list[count]=pos;
}
file.close();
sort_index();

buffer.erase();
}

string secondary_index::extract_Name(string buffer)
{string USN,Name;
int i=0;
USN.erase();
while(buffer[i]!=’|')
USN+=buffer[i++];
Name.erase();
i++;
while(buffer[i]!=’|')
Name+=buffer[i++];
return Name;
}

void secondary_index::sort_index()
{
int i,j,temp_Address;
string temp_Name;
for(int i=0;i<count;i++)
{
for(int j=i+1;j<=count;j++)
{
if(Name_list[i]>Name_list[j])
{
temp_Name=Name_list[i];
Name_list[i]=Name_list[j];
Name_list[j]=temp_Name;
temp_Address=Address_list[i];
Address_list[i]=Address_list[j];
Address_list[j]=temp_Address;

}

}
}
}

void secondary_index::insert()
{
string   USN,Name,Branch,sem,buffer;
int semester,pos;
fstream file ;
cout<< “n USN:”;
cin>>USN;
cout<< “n Name:”;
cin>>Name;
cout<< “nBranch:” ;
cin>>Branch;
cout<< “nSEMESTER:”;
cin>>semester;
stringstream out;
out<<semester;
sem=out.str();
buffer=USN+’|'+Name+’|'+Branch+’|'+sem+’$'+’n';
file.open(“1.txt”,ios::out|ios::app);
pos=file.tellp();
file<<buffer;
file.close();
Name_list[++count]=Name;

Address_list[count]=pos;
sort_index();
}
int secondary_index::search_index(string key){
int low=0,high=count,mid=0,flag=0;
while(low<=high){
mid=(low+high)/2;
if(Name_list[mid]==key){
flag=1;
break;
}
if(Name_list[mid]>key)
high=mid-1;
else
low=mid+1;
}
if(flag){
return mid;
}
else
return -1;
}
void secondary_index::search(string key){
int pos=0,t;
string buffer;
buffer.erase();
pos=search_index(key);
if(pos>=0){
read_from_file(pos);
t=pos;
while(Name_list[++t]==key)
read_from_file(t);
t=pos;
while(Name_list[--t]==key)
read_from_file(t);
}
else
cout<<”n”<<”Not found”;
}
void secondary_index::read_from_file(int pos){
int address;
string buffer;
/*for(int i=pos;i<count;i++){
Name_list[i]=Name_list[i+1];
Address_list[i]=Address_list[i+1];
}    */
fstream file;
file.open(“1.txt”);
address=Address_list[pos];
file.seekp(address,ios::beg);
getline(file,buffer);
cout<<endl<<”Found the record:”<<buffer;
file.close();
}
void secondary_index::remove(string key){
int pos=0,t,ch;
string buffer;
buffer.erase();
pos=search_index(key);
if(pos>=0){
read_from_file(pos);
cout<<endl<<”delete ?”;
cin>>ch;
if(ch)
delete_from_file(pos);
t=pos;
while(Name_list[++t]==key){
read_from_file(t);
cout<<endl<<”Delete?”;
cin>>ch;
if(ch)
delete_from_file(t);
}
t=pos;
while(Name_list[--t]==key){
read_from_file(t);
cout<<endl<<”Delete?”;
cin>>ch;
if(ch)
delete_from_file(t);
}
}
else
cout<<”nnNot foundn”;
}
void secondary_index::delete_from_file(int pos){
char del_ch=’*';
int i,address;
if(pos>=0){
fstream file;
file.open(“1.txt”);
address=Address_list[pos];
file.seekp(address,ios::beg);
file.put(del_ch);
cout<<endl<<”nnRecord deleted:”;
file.close();
}
for(int i=pos;i<count;i++){
Name_list[i]=Name_list[i+1];
Address_list[i]=Address_list[i+1];
}

count–;
}
int main(){
int ch;
string key;
secondary_index i1;
i1.create_index();
while(1){
cout<<”nMain Menun1:Add()n2:Search()n3:Delete()n4:Exit()nEnter the choice”;
cin>>ch;
switch(ch){
case 1:cout<<”Data n”;
i1.insert();
break;
case 2:cout<<”Enter the namen”;
cin>>key;
i1.search(key);
break;
case 3:cout<<”Enter the Name”;
cin>>key;
i1.remove(key);
break;
case 4: return 0;
default:cout<<”Wrong Choice!!!!!!!nn”;

}
}
}

System Software Lab Programs ( Lex and Yaac Programs ) 5b

// June 13th, 2009 // Comments // Educational, Engineering, Unix and System Software Lab

Subject : System Software Laboratory

Branch : Information Science & Engineering

Semester : 6

University : VTU

………………………………………………………………………………………………………………………….
PART – A

………………………………………………………………………………………………………………………….

5b. Program to recognize strings ‘aaab’, ‘abbb’, ‘ab’ and ‘a’ using the grammar (anbn, n>= 0).

5b.l

%{
#include<stdio.h>
#include “y.tab.h”
%}

%%
[a] return A;
[b] return B;
. return yytext[0];
n return yytext[0];
%%
——————————————

5b.y

%{
#include<stdio.h>
%}
%token A B
%%
input:expr ‘n’ {return 0;}
expr: X
X: A X B|;
%%

main()
{
printf(“nEnter string: “);
if(!yyparse())
{
printf(“nValid”);
exit(0);
}
}
int yyerror()
{
printf(“nInvalid”);
return 1;
}
int yywrap()
{
return 1;
}

System Software Lab Programs ( Lex and Yaac Programs ) 5a

// June 12th, 2009 // Comments // Educational, Engineering, Unix and System Software Lab

Subject : System Software Laboratory

Branch : Information Science & Engineering

Semester : 6

University : VTU

………………………………………………………………………………………………………………………….
PART – A

………………………………………………………………………………………………………………………….

5) a. Program to evaluate an arithmetic expression involving operators +, -, * and /.

5a.l

%{
#include “y.tab.h”
extern int yylval;
%}

%%
[0-9]+ { yylval=atoi(yytext);return NUM;}
[ t];
n return 0;
. return yytext[0];
%%

————————————————-

5a.y
/* 5a.y */
%{
#include<stdio.h>
%}
%token NUM
%left ‘-”+’
%left ‘*”/’

%%
start: expr    {printf(“nValid expression.nValue: %d”,$1);}

expr: expr’+'expr   {$$=$1+$3;}
|expr’-'expr    {$$=$1-$3;}
|expr’*'expr    {$$=$1*$3;}
|expr’/'expr     {if($3==0)
yyerror(“Divide by zero”);
else
$$=$1/$3;
}
|’(‘ expr ‘)’  {$$=$2;}
|NUM
;
%%

main()
{
printf(“nEnter an expression: “);
yyparse();
return(0);
}

int yyerror(char *msg)
{
printf(“n%s”,msg);
printf(“nInvalid expression”);
exit(0);
}

System Software Lab Programs ( Lex and Yaac Programs ) 4a

// June 11th, 2009 // Comments // Educational, Engineering, Unix and System Software Lab

Subject : System Software Laboratory

Branch : Information Science & Engineering

Semester : 6

University : VTU

………………………………………………………………………………………………………………………….
PART – A

………………………………………………………………………………………………………………………….

4) a. Program to recognize a valid arithmetic expression that uses operators+, -, * and /.

4a.l

%{
#include “y.tab.h”
extern int yylval;
%}

%%
[0-9]+ {yylval=atoi(yytext); return NUM; }
[ t] ;
n return 0;
. return yytext[0];
%%

———————————————–

4a.y

%{
#include<stdio.h>
%}

%%

%token NUM
%left ‘+’ ‘-’
%left ‘+’ ‘-’
%nonassoc UMINUS

%%

e:e’+'e |
e’-'e |
e’*'e |
e’/'e {if($3==0)  {printf(“n DIVIDE BY ZERO ERROR”); exit(0);}} |
‘(‘e’)’ |
‘-’e %prec UMINUS |
NUM
;
%%

yyerror()
{
printf(“invalid exppressionn”);
exit(0);
}

int main()
{
printf(“enter an expression:”);
yyparse();
printf(“valid expression”);
return 0;
}



System Software Lab Programs ( Lex and Yaac Programs ) 3.l

// June 10th, 2009 // Comments // Educational, Engineering, Unix and System Software Lab

Subject : System Software Laboratory

Branch : Information Science & Engineering

Semester : 6

University : VTU

………………………………………………………………………………………………………………………….
PART – A

………………………………………………………………………………………………………………………….

3) Program to recognize and count the number of identifiers in a given
input file.

%{
int id=0;
%}

ID [_a-zA-Z][a-zA-Z0-9]*
DECLN “int”|”float”|”char”|”short”|”double”|”long”|”unsigned”
%x DEFN

%%
{DECLN}    {BEGIN DEFN;}
<DEFN>{ID}, id++;
<DEFN>{ID}; id++;
<*>n ;
<*>. ;
%%

main(int argc, char **argv)
{
if(argc==2)
{
yyin=fopen(argv[1],”r”);
yylex();
printf(“n Number of identifiers : %dn”,id);
}
else
printf(“n Usage :%s <file>n”,argv[0]);
}

System Software Lab Programs ( Lex and Yaac Programs )2b.l

// June 9th, 2009 // Comments // Educational, Engineering, Unix and System Software Lab

Subject : System Software Laboratory

Branch : Information Science & Engineering

Semester : 6

University : VTU

………………………………………………………………………………………………………………………….
PART – A

………………………………………………………………………………………………………………………….

2b. b. Program to recognize whether a given sentence is simple or compound.

%{
#include<stdio.h>
int F0=0,F1=0,F2=0,error=0,l1=0,l2=0;
%}

verb am|run|sit|did|study|is|large|go|come
subject [a-zA-Z]+
compnd “and”|”but”|”also”|”either”|”neither”|”yet”|”still”|”consequences”

%%
{verb} { if(F2==1)
l2=1;
F2=1;
if(F1==0)
error=1;
}

{compnd} { F0=1; }
{subject} { if(F1!=0)
l1=1;
F1++;
}
%%

main()
{
printf(“n Enter a sentence: “);
yylex();

if(error==1 || F2==0 || F1==0)
{
printf(“n Invalid sentence”);
exit(0);
}

if(F0==1 && l1==1 && l2==1)
printf(“n Compound sentencen”);
else
printf(” nSimple sentencen”);
}