Category : SS LAB

2 – Develop, Implement and Execute a program using YACC tool to recognize all strings ending with b preceded by n a’s using the grammar an b (note: input n value)lab2.l – PROGRAM%{#include “y.tab.h”%}%%a {return A;}b {return B;}[n] return ‘n’;%% lab2.y – PROGRAM%{#include<stdio.h>#include<stdlib.h>%}%token A B%%input:s’n’ {printf(“Successful Grammarn”);exit(0);}s: A s1 B| B s1: ; | A ..

Read more

10 – a). Design, develop and implement a C/C++/Java program to simulate a numerical calculator.lab10a.c PROGRAM#include <stdio.h> int main(){ char operator; float num1, num2, result; printf(“Simulation of a Simple Calculatornn”); printf(“Enter two numbers n”); scanf(“%f %f”, &num1,&num2); fflush(stdin); printf(“nEnter the operator [+,-,*,/] n”); scanf(“%s”, &operator); switch(operator) { case ‘+’: result = num1 + num2; break; ..

Read more

5 – Design, develop and implement a C/Java program to generate the machine code usingTriples for the statement A = -B * (C +D) whose intermediate code in three-address form:T1 = -BT2 = C + DT3 = T1 + T2A = T3lab5.c – PROGRAM#include<stdio.h>#include<stdlib.h>#include<ctype.h> char op[2],arg1[5],arg2[5],result[5];int main(){    FILE *fp1,*fp2;    fp1=fopen(“input.txt”,”r”);    fp2=fopen(“output.txt”,”w”);    while(!feof(fp1))    ..

Read more

9 – Design, develop and implement a C/C++/Java program to implement page replacement algorithms LRU and FIFO. Assume suitable input required to demonstrate the results. lab9.c PROGRAM#include<stdio.h>#include<stdlib.h> void FIFO(char [ ],char [ ],int,int);void lru(char [ ],char [ ],int,int);void opt(char [ ],char [ ],int,int); int main(){    int ch,YN=1,i,l,f;    char F[10],s[25];    printf(“nEnter the no ..

Read more

12. Write a C++ program to emulate the Unix ln command lab12.cpp PROGRAM #include<iostream> #inculde<unistd.h> int main(int argc, char* argv[]) { using namespace std; if(argc!=3) { cout<<“Usage ./a.out sourcefile destination filen”; return 0; } if(link(argv[1],argv[2])==-1) { cout<<“cant linkn”; return 1; } else { cout<<“Files have been Linkedn”; } return 0; } OUTPUT 🙁 click on image ..

Read more

7 – Design, develop and implement a C/C++/Java program to simulate the working of Shortest remaining time and Round Robin (RR) scheduling algorithms. Experiment with different quantum sizes for RR algorithm.lab7.c PROGRAM// CPU Scheduling -Round Robin#include<stdio.h>struct process{ char name; int at,bt,wt,tt,rt; int completed;}p[10]; int n;int q[10];  //queueint front=-1,rear=-1;void enqueue(int i){    if(rear==10)        ..

Read more

1 – B) Write YACC program to evaluate arithmetic expression involving operators: +, -, *, and /lab1b.l – PROGRAM %{#include “y.tab.h”extern yylval;%} %%[0-9]+ {yylval=atoi(yytext);return num;}[+-*/] {return yytext[0];}[)] {return yytext[0];}[(] {return yytext[0];}. {;}n {return 0;}%% lab1b.y – PROGRAM %{#include<stdio.h>#include<stdlib.h>%}%token num%left ‘+’ ‘-‘%left ‘*’ ‘/’ %%input:exp{printf(“%dn”,$$);exit(0);}exp:exp’+’exp{$$=$1+$3;}|exp’-‘exp{$$=$1-$3;}|exp’*’exp{$$=$1*$3;}|exp’/’exp{ if($3==0){printf(“Divide by Zero errorn”);exit(0);} else  $$=$1/$3;}|'(‘exp’)'{$$=$2;}|num{$$=$1;};%% int yyerror(){ printf(“error”); exit(0);} int main(){ printf(“Enter an expression:n”); ..

Read more

3 – Design, develop and implement YACC/C program to construct Predictive / LL(1) Parsing Table for the grammar rules: A ®aBa , B ®bB | e. Use this table to parse the sentence: abba$ lab3.c – PROGRAM /*GRAMMER RULES —- A ->aBa , B ->bB | @*/ #include<stdio.h> #include<stdlib.h> #include<string.h> char prod [3][10]={“A->aBa”,”B->bB”,”B->@”}; char first[3][10]={“a”,”b”,”@”}; char follow[3][10]={“$”,”a”,”a”}; ..

Read more

10 – b). Design, develop and implement a C/C++/Java program to simulate page replacement technique.lab10b.c PROGRAM#include<stdio.h> int main(){      int reference_string[10], page_faults = 0, m, n, s, pages, frames;      printf(“nEnter Total Number of Pages:t”);      scanf(“%d”, &pages);      printf(“nEnter values of Reference String:n”);      for(m = 0; m < ..

Read more

6 – a) Write a LEX program to eliminate comment lines in a C program and copy the resulting program into a separate file. lab6.l – PROGRAM%{#include<stdio.h>int sl=0;int ml=0;%}%%“/*”[a-zA-Z0-9′ ‘tn]+”*/” ml++;“//”.* sl++;%% main(){ yyin=fopen(“f1.c”,”r”); yyout=fopen(“f2.c”,”w”); yylex(); fclose(yyin); fclose(yyout); printf(“n Number of single line comments are = %dn”,sl); printf(“nNumber of multiline comments are =%dn”,ml);} f1.c FILE#include<stido.h> int main(){ // ..

Read more