Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pls merge. thenks #39

Open
wants to merge 46 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
9e8687d
Create sstf.c
meghna-pk Oct 9, 2022
84b688e
Merge pull request #5 from meghna-pk/patch-1
neha-ajith Oct 9, 2022
baabcae
Create look.c
meghna-pk Oct 9, 2022
4c6444e
Create insert.c
meghna-pk Oct 9, 2022
8c676d8
Merge pull request #6 from meghna-pk/patch-2
neha-ajith Oct 9, 2022
21fe7a6
Merge pull request #7 from meghna-pk/patch-3
neha-ajith Oct 9, 2022
71104d9
Create select.c
meghna-pk Oct 9, 2022
f5ebb84
Merge pull request #8 from meghna-pk/patch-4
neha-ajith Oct 9, 2022
80b2e4b
Create fcfs.c
meenu-km Oct 9, 2022
851ccec
Create scan.c
meenu-km Oct 9, 2022
d2ee660
Create cscan1.c
meenu-km Oct 9, 2022
795f3c7
Create fifo1.c
meenu-km Oct 9, 2022
96d3fac
Merge pull request #12 from meenu-km/patch-4
neha-ajith Oct 9, 2022
7f169d8
Merge pull request #11 from meenu-km/patch-3
neha-ajith Oct 9, 2022
9b14f2e
Merge pull request #10 from meenu-km/patch-2
neha-ajith Oct 9, 2022
b3f2711
Merge pull request #9 from meenu-km/patch-1
neha-ajith Oct 9, 2022
e7854ee
Create Leapyear.c
Dhwanivijayan-30102000 Oct 10, 2022
8cbf984
Create Fibonacci.c
Dhwanivijayan-30102000 Oct 10, 2022
6fb2cc6
Create Primenumber.c
Dhwanivijayan-30102000 Oct 10, 2022
8e02756
Create Factorial.c
Dhwanivijayan-30102000 Oct 10, 2022
32f69f0
Merge pull request #16 from Dhwanivijayan-30102000/patch-4
neha-ajith Oct 10, 2022
943cfe3
Merge pull request #15 from Dhwanivijayan-30102000/patch-3
neha-ajith Oct 10, 2022
87892a1
Merge pull request #14 from Dhwanivijayan-30102000/patch-2
neha-ajith Oct 10, 2022
38315ed
Merge pull request #13 from Dhwanivijayan-30102000/patch-1
neha-ajith Oct 10, 2022
5960dc5
cleaned up + formatted
tamton-aquib Oct 13, 2022
1cd72cb
Merge pull request #17 from tamton-aquib/master
neha-ajith Oct 14, 2022
a6a2c61
Added lex program to convert abc to ABC
AshwinC8 Oct 16, 2022
1fb7476
Merge branch 'neha-ajith:master' into master
AshwinC8 Oct 16, 2022
744cb8d
Merge pull request #18 from AshwinC8/master
neha-ajith Oct 26, 2022
8093625
Fixed lex program
AshwinC8 Oct 26, 2022
f6b51f9
Merge branch 'master' of https://github.com/AshwinC8/HacktoberFest2022
AshwinC8 Oct 26, 2022
3c8865e
Added vouwels consonants lex program
AshwinC8 Oct 26, 2022
f983ee5
Added word, line, char count lex progra,
AshwinC8 Oct 26, 2022
9c05b85
validation of identifiers using YACC
AshwinC8 Oct 26, 2022
7649aa3
Merge pull request #21 from AshwinC8/h4
neha-ajith Oct 26, 2022
33c8cee
Arranged Compiler Design programs
AshwinC8 Oct 26, 2022
bf9770e
removed initial lex program folder
AshwinC8 Oct 26, 2022
82158fe
better formatting + little cleanup
tamton-aquib Oct 28, 2022
bc6fb32
Merge pull request #23 from tamton-aquib/master
neha-ajith Oct 29, 2022
ee0cdc6
Merge pull request #22 from AshwinC8/master
neha-ajith Oct 29, 2022
72874ad
Merge branch 'alan-thomas-shaji:master' into master
neha-ajith Oct 29, 2022
ecc597a
Create validParenthesis.py
mhdafh7 Oct 30, 2022
da2c01e
Create Two Pass_Assembler_Pass_1.c
Nikham-Sakeer Oct 30, 2022
57642f8
Create Two Pass_Asemble_Pass_2.c
Nikham-Sakeer Oct 30, 2022
f3d5bc7
Merge pull request #25 from Nikham-Sakeer/master
neha-ajith Oct 31, 2022
f9e9065
Merge pull request #24 from mhdafh7/patch-1
neha-ajith Oct 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions COHENSUTHERLAND_LINECLIPPING_ALGO.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include<graphics.h>
#include<process.h>
#include<dos.h>

void main()
{
int gd=DETECT,gm;
Expand Down Expand Up @@ -144,11 +145,3 @@ void main()
closegraph();
getch();
}








16 changes: 16 additions & 0 deletions Compiler_Design/lex_programs/abc.l
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
%option noyywrap
%{
#include<string.h>
%}

%%
abc {strcpy(yytext, "ABC"); ECHO;}
. ECHO;
%%

int main(){
yyin = fopen("abc.txt", "r");
yyout = fopen("resul_abc.txt", "w");
yylex();
return 0;
}
3 changes: 3 additions & 0 deletions Compiler_Design/lex_programs/abc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sdjkagkdfjahsd abc
\abc
abc
16 changes: 16 additions & 0 deletions Compiler_Design/lex_programs/vc.l
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
%option noyywrap
%{
int vowels=0, consonants=0;
%}

%%
[aeiouAEIOU] vowels++;
[a-zA-Z] consonants++;
%%

int main(){
yylex();
printf("\n\nvowels=%d \nconsonants=%d\n", vowels, consonants);
return 0;
}

17 changes: 17 additions & 0 deletions Compiler_Design/lex_programs/wcl.l
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
%option noyywrap
%{
int words=0, chars=0, lines=0;
%}

%%
[a-zA-Z]+ {words++; chars+=yyleng;}
\n {chars++; lines++;}
. chars++;
%%


int main(){
yylex();
printf("\n\nwords=%d \ncharacters= %d \nlines= %d \n", words, chars, lines);
return 0;
}
12 changes: 12 additions & 0 deletions Compiler_Design/yacc_programs/iden.l
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
%option noyywrap
%{
#include "iden.tab.h"
%}

%%
[0-9] { return DIGIT;}
[_a-zA-Z] {return LETTER;}
\n {return NL;}
. {return yytext[0];}
%%

25 changes: 25 additions & 0 deletions Compiler_Design/yacc_programs/iden.y
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
%{
#include<stdio.h>
#include<stdlib.h>
%}

%token NL DIGIT LETTER

%%
stmt: variable NL {printf("Valid Identifier\n"); return 0;}
variable: LETTER alphanumeric
alphanumeric: LETTER alphanumeric | DIGIT alphanumeric | LETTER | DIGIT

%%
int main()
{
printf("Enter an Identifier\n");
yyparse();
return 0;
}
int yyerror()
{
printf("Invalid Identifier!\n");
exit(0);
}

24 changes: 12 additions & 12 deletions Description.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#include<stdio.h>
#include<conio.h>
void main()
{
printf("WELCOME TO HACKTOBERFEST 2020!!!!!");
printf("So let's get started!");
printf("I guess everybody is a noobie here");
printf("My whole life was a bruh moment");
printf("\n What is life, anyway?");
printf("Hello there,this id Anushree VInod");
printf("My whole life was just great");
printf("With a little sunshine, we can make it through");
#include <stdio.h>
#include <conio.h>

void main() {
printf("WELCOME TO HACKTOBERFEST 2020!!!!!");
printf("So let's get started!");
printf("I guess everybody is a noobie here");
printf("My whole life was a bruh moment");
printf("\n What is life, anyway?");
printf("Hello there,this id Anushree VInod");
printf("My whole life was just great");
printf("With a little sunshine, we can make it through");
}
19 changes: 19 additions & 0 deletions Factorial.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <stdio.h>
int main() {
int n, i;
unsigned long long fact = 1;
printf("Enter an integer: ");
scanf("%d", &n);

// shows error if the user enters a negative integer
if (n < 0)
printf("Error! Factorial of a negative number doesn't exist.");
else {
for (i = 1; i <= n; ++i) {
fact *= i;
}
printf("Factorial of %d = %llu", n, fact);
}

return 0;
}
28 changes: 28 additions & 0 deletions Fibonacci.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <stdio.h>
int main() {

int i, n;

// initialize first and second terms
int t1 = 0, t2 = 1;

// initialize the next term (3rd term)
int nextTerm = t1 + t2;

// get no. of terms from user
printf("Enter the number of terms: ");
scanf("%d", &n);

// print the first two terms t1 and t2
printf("Fibonacci Series: %d, %d, ", t1, t2);

// print 3rd to nth terms
for (i = 3; i <= n; ++i) {
printf("%d, ", nextTerm);
t1 = t2;
t2 = nextTerm;
nextTerm = t1 + t2;
}

return 0;
}
27 changes: 27 additions & 0 deletions Leapyear.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <stdio.h>
int main() {
int year;
printf("Enter a year: ");
scanf("%d", &year);

// leap year if perfectly divisible by 400
if (year % 400 == 0) {
printf("%d is a leap year.", year);
}
// not a leap year if divisible by 100
// but not divisible by 400
else if (year % 100 == 0) {
printf("%d is not a leap year.", year);
}
// leap year if not divisible by 100
// but divisible by 4
else if (year % 4 == 0) {
printf("%d is a leap year.", year);
}
// all other years are not leap years
else {
printf("%d is not a leap year.", year);
}

return 0;
}
31 changes: 31 additions & 0 deletions Primenumber.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <stdio.h>

int main() {

int n, i, flag = 0;
printf("Enter a positive integer: ");
scanf("%d", &n);

// 0 and 1 are not prime numbers
// change flag to 1 for non-prime number
if (n == 0 || n == 1)
flag = 1;

for (i = 2; i <= n / 2; ++i) {

// if n is divisible by i, then n is not prime
// change flag to 1 for non-prime number
if (n % i == 0) {
flag = 1;
break;
}
}

// flag is 0 for prime numbers
if (flag == 0)
printf("%d is a prime number.", n);
else
printf("%d is not a prime number.", n);

return 0;
}
33 changes: 16 additions & 17 deletions SCAN Disk Scheduling.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include<stdio.h>
#include<stdlib.h>


void main(){
int req_sq[10],i,j,n,head,seek_count=0,distance,rl[10],rg[10],irl=-1,irg=-1,temp;
float avg;
Expand All @@ -18,30 +17,30 @@ void main(){
for(i=0;i<n;i++){
if(req_sq[i]<=head){
rl[++irl]=req_sq[i];

}
else{
rg[++irg]=req_sq[i];
}
rg[++irg]=req_sq[i];
}
}
for(i=0;i<irl;i++){
for(j=i+1;j<irl+1;j++){
if(rl[j]>rl[i]){
temp=rl[i];
rl[i]=rl[j];
rl[j]=temp;
}
if(rl[j]>rl[i]){
temp=rl[i];
rl[i]=rl[j];
rl[j]=temp;
}

}
}
for(i=0;i<irg;i++){
for(j=i+1;j<irg+1;j++){
if(rg[j]<rg[i]){
temp=rg[i];
rg[i]=rg[j];
rg[j]=temp;
}
if(rg[j]<rg[i]){
temp=rg[i];
rg[i]=rg[j];
rg[j]=temp;
}

}
}
for(i=0;i<=irl;i++){
Expand All @@ -56,7 +55,7 @@ void main(){
seek_count+=distance;
head=rg[i];
}
avg=seek_count/n;
avg = seek_count/n;
printf("\n\n ============================================================\n\n");
printf(" TOTAL SEEK TIME : %d",seek_count);
printf("\n AVERAGE SEEK TIME : %for",avg);
Expand Down
81 changes: 81 additions & 0 deletions Two Pass_Asemble_Pass_2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
int main()
{
FILE *fint,*ftab,*flen,*fsym,*fobj;
int op1[10],txtlen,txtlen1,i,j=0,len;
char add[5],symadd[5],op[5],start[10],temp[30],line[20],label[20],mne[10],operand[10],symtab[10],opmne[10];
fint=fopen("intermediate.txt","r");
flen=fopen("length.txt","r");
ftab=fopen("optab.txt","r");
fsym=fopen("symtab.txt","r");
fobj=fopen("object_program.txt","w");
fscanf(fint,"%s%s%s%s",add,label,mne,operand);
if(strcmp(mne,"START")==0)
{
strcpy(start,operand);
fscanf(flen,"%x",&len);
}
printf("H^%s^%s^%x\nT^00%s^15^",label,start,len,start);
fprintf(fobj,"H^%s^%s^%x\nT^00%s^15^",label,start,len,start);
fscanf(fint,"%s%s%s%s",add,label,mne,operand);
while(strcmp(mne,"END")!=0)
{
fscanf(ftab,"%s%s",opmne,op);
while(!feof(ftab))
{
if(strcmp(mne,opmne)==0)
{
fclose(ftab);
fscanf(fsym,"%s%s",symadd,symtab);
while(!feof(fsym))
{
if(strcmp(operand,symtab)==0)
{
printf("%s%s^",op,symadd);
fprintf(fobj,"%s%s^",op,symadd);
break;
}
else
fscanf(fsym,"%s%s",symadd,symtab);
}
break;
}
else
fscanf(ftab,"%s%s",opmne,op);
}
if((strcmp(mne,"BYTE")==0)||(strcmp(mne,"WORD")==0))
{
if(strcmp(mne,"WORD")==0)
{
printf("00000%s^",operand);
fprintf(fobj,"00000%s^",operand);
}
else
{
len=strlen(operand);
for(i=2;i<len;i++)
{
printf("%x",operand[i]);
fprintf(fobj,"%x",operand[i]);
}
printf("^");
fprintf(fobj,"^");
}
}
fscanf(fint,"%s%s%s%s",add,label,mne,operand);
ftab=fopen("optab.txt","r");
fseek(ftab,SEEK_SET,0);
}
printf("\nE^00%s",start);
fprintf(fobj,"\nE^00%s",start);
fclose(fint);
fclose(ftab);
fclose(fsym);
fclose(flen);
getch();
return 0;
}
Loading