Posts

Showing posts from 2012

Install Music Video-Multimedia at easy in Ubuntu Linux

Image
WE can install most of the restricted features in Ubuntu in a easy way.You just need to install restricted extras. Open terminal and type  sudo apt-get update sudo apt-get install ubuntu-restricted-extras

How To Install LEX and YACC in Linux or Ubuntu

Image
To program LEX programs and yacc programs you need to install two packages in Ubuntu 1:Flex -to make the Lex program work 2.Bison -to make the yacc programs work To install,Open terminal and do the following...  1.To install Flex sudo apt-get upgrade sudo apt-get install flex 2.To install Lex sudo apt-get upgrade sudo apt-get install bison And its done ..!!!

C Graphics Program For Boundary Fill in C

Image
C Graphics Program For Boundary Fill in C Source Code:- 1:  //Program to implement Boundary Fill Algorithm   2:  #include <graphics.h>   3:  #include <stdlib.h>   4:  #include <stdio.h>   5:  #include <conio.h>   6:  #include "grplib.h"   7:  int bfill(int x,int y,int f,int b)   8:       {   9:       if(getpixel(x,y) !=b && getpixel(x,y)!=f)   10:            {   11:            putpixel(x,y,f);   12:            bfill(x+1,y,f,b);   13:            bfill(x-1,y,f,b);   14:            bfill(x,y+1,f,b);   15:            bfill(x,y-1,f,b);   16:            }   17:       return 0;   18:       }   19:  int main(void)   20:  {   21:    int gdriver = DETECT, gmode;   22:    int x,y;   23:    int bx,by;   24:    int vert[10],n,i;   25:    int left, top, right, bottom;   26:    initgraph(&gdriver, &gmode, "");   27:    printf(" Boundary fill :\n");   28:    printf(" Enter the no. of ver

C Graphics Program For 3D Transformation

Image
C Graphics Program For 3D Transformation Source Code:- 1:  //Program to implement 3D Transformation   2:  #include<math.h> 3:  #include<stdio.h> 4:  #include<process.h> 5:  #include<iostream.h> 6:  #include<conio.h> 7:  #include<graphics.h> 8:  #include "grplib.h" 9:  #define X 0 10:  #define Y 1 11:  int getx(float mat[4][1]) 12:       { 13:       return ceil(mat[0][0]); 14:       } 15:  int gety(float mat[4][1]) 16:       { 17:       return ceil(mat[1][0]); 18:       } 19:  int getz(float mat[4][1]) 20:       { 21:       return ceil(mat[2][0]); 22:       } 23:  void create_mat_pnt(float mat[4][1],int x,int y,int z) 24:       { 25:       mat[0][0]=x; 26:       mat[1][0]=y; 27:       mat[2][0]=z; 28:       mat[3][0]=1; 29:       } 30:  void create_mat_tran(float mat[4][4],int tx,int ty,int tz) 31:       { 32:       int i,j; 33:       for(i=0;i<4;i++) 34:       for(j=0;j<4;j++) 35:    

C Graphics Program For 2 D Transformation

Image
C Graphics Program For 2 D Transformation Source Code:- 1:  //Program to implement 2D Transformation   2:  #include<math.h> 3:  #include<stdio.h> 4:  #include<process.h> 5:  #include<iostream.h> 6:  #include<conio.h> 7:  #include<graphics.h> 8:  #include "grplib.h" 9:  #define X 0 10:  #define Y 1 11:  int getx(float mat[3][1]) 12:       { 13:       return ceil(mat[0][0]); 14:       } 15:  int gety(float mat[3][1]) 16:       { 17:       return ceil(mat[1][0]); 18:       } 19:  void create_mat_pnt(float mat[3][1],int x,int y) 20:       { 21:       mat[0][0]=x; 22:       mat[1][0]=y; 23:       mat[2][0]=1; 24:       } 25:  void create_mat_tran(float mat[3][3],int tx,int ty) 26:       { 27:       int i,j; 28:       for(i=0;i<3;i++) 29:       for(j=0;j<3;j++) 30:            { 31:            if(i==j) 32:            { 33:            mat[i][j]=1.0; 34:            } 35:            else 36:  

Lex Program to find the Syntax of Scanf()

Image
Lex Program to find the Syntax of Scanf() Source Code:- 1:  %{   2:  #include<stdio.h> 3:  #include<ctype.h> 4:  int i=0,j=0; 5:  %} 6:  a "%d"|"%f"|"%c"|"%s" 7:  id [a-zA-Z][a-zA-Z0-9]* 8:  %% 9:  scanf\((\"({a}*|.*)*\"(,\&{id})*\))\; {for(i=0;i<yyleng;i++){if(yytext[i]=='%') 10:  j++; 11:  if(yytext[i]==',') 12:  j--; 13:  } 14:  if(j==0) 15:  printf("\ncorrect");   16:  else   17:  printf("incorrect"); 18:  } 19:  %% 20:  main() 21:  { yyin=fopen("file13.c","r"); 22:  yylex(); 23:  } 24:  int yywrap() 25:  {return 1; 26:  }      

Lex Program TO find Syntax of Printf()

Image
Lex Program TO find Syntax of Printf() Source Code:- 1:  %{   2:  #include<stdio.h>   3:  #include<ctype.h>   4:  int i=0,j=0;   5:  %}   6:  a "%d"|"%f"|"%c"|"%s"   7:  id [a-zA-Z][a-zA-Z0-9]*   8:  %%   9:  printf\((\"({a}*|.*)*\"(,{id})*\))\; {for(i=0;i<yyleng;i++){if(yytext[i]=='%')   10:  j++;   11:  if(yytext[i]==',')   12:  j--;   13:  }   14:  if(j==0)   15:  printf("\ncorrect");    16:  else    17:  printf("incorrect");   18:  }   19:  %%   20:  main()   21:  { yyin=fopen("file12.c","r");   22:  yylex();   23:  }   24:  int yywrap()   25:  {return 1;   26:  }                    

Lex Program To Check The Syntax of For Loop

Image
Lex Code To check the syntax of For loop:- Source code:- 1:  %{   2:  #include<stdio.h> 3:  #include<ctype.h> 4:  int c; 5:  %} 6:  op "++"|"--" 7:  rop "<"|">"|"<="|">="|"=="|"!=" 8:  id [a-zA-Z][a-zA-Z0-9]* 9:  no [0-9]* 10:  pp [\n\t" "] 11:  %% 12:  for\({id}=({no}|{id})\)?(,{id}=({no}|{id}))*\;({id}{rop}({id}|{no}))?\;({id}{op})?(,{id}{op})*\)\;?{pp}*\("{"(.*\n)*.*"}") {printf("correct");c=0;} 13:  .*    {printf("\nwrong");} 14:  %% 15:  main() 16:  { yyin=fopen("file11.c","r"); 17:  yylex(); 18:  } 19:  int yywrap() 20:  {return 1; 21:  }

Implement Macro in C Program Example

Image
Implementing macro processor in C :- Included :- source file,input file,expanded file Source code:- 1:  #include<stdio.h>   2:  #include<conio.h> 3:  #include<string.h> 4:  void GETLINE(); 5:  void PROCESSLINE(); 6:  void DEFINE(); 7:  void EXPAND(); 8:   FILE *expanded; 9:   FILE *input; 10:   char label[10],opcode[10],operand[25]; 11:   char line[20]; 12:   int namcount=0,defcount=0; 13:   int EXPANDING; 14:   int curr; 15:   struct namtab 16:   { 17:   char name[10]; 18:   int start,end; 19:  }mynamtab[15]; 20:   struct deftab 21:   { 22:      char macroline[25]; 23:   }mydeftab[25]; 24:  struct argtab 25:  { 26:      char arg[3][9]; 27:   }myargtab; 28:  ///MACRO MAIN 29:  int main() 30:  { 31:    EXPANDING=0; 32:    input =fopen("input.txt","r");               //INPUT FILE open to read 33:   expanded=fopen("expanded.txt","w"); 34:  GETLINE(); 35:     while(strcmp(opcode,&quo

Useful / Essential commands in terminal /unix/Ubuntu Part 1

Image
I am only listing some of the commands.. the rest of the commands will be on the next part.. The important Commands you need to know are :- pwd :- Print Working Directory ls :- List Files.It list all the files in the current directory ls -l :- It also list files, but with more details such as permission, group etc  cat  :- A line editor, Type the file name in the position cd :-change directory For Eg :- cd home mkdir :- Make directory ,to create a directory rmdir  :- To Remove a directory  cd .. :- TO go one step backward in path Tip :- To hide a file inn Linux/Ubuntu we can use "." as prefix   to hide a file.To show it in nautilus we can use  Ctrl +h to show hidden files and ls -a  in terminal

How To Implement Follow Of An Expression in C

Image
How To Implement Follow Of An Expression in C :- 1:  #include<stdio.h>   2:  #include<string.h> 3:  int n,m=0,p,i=0,j=0; 4:  char a[10][10],f[10]; 5:  void follow(char c); 6:  void first(char c); 7:  int main() 8:  { 9:       int i,z; 10:       char c,ch; 11:       printf("Enter the no.of productions:"); 12:       scanf("%d",&n); 13:       printf("Enter the productions(epsilon=$):\n"); 14:       for(i=0;i<n;i++) 15:            scanf("%s%c",a[i],&ch); 16:       do 17:       { 18:            m=0; 19:            printf("Enter the element whose FOLLOW is to be found:"); 20:            scanf("%c",&c); 21:            follow(c); 22:            printf("FOLLOW(%c) = { ",c); 23:            for(i=0;i<m;i++) 24:                 printf("%c ",f[i]); 25:            printf(" }\n"); 26:            printf("Do you want to continue(0/1)?"

How To Implement FIRST of an Expression in C

Image
How To Implement FIRST of an Expression in C:- if You need The Exe ,i can prvide it Source Code :- 1:  #include<stdio.h>   2:  #include<ctype.h> 3:  #include<conio.h> 4:  void FIRST(char ); 5:  int count,n=0; 6:  char prodn[10][10], first[10]; 7:  main() 8:  { 9:     int i,choice; 10:     char c,ch; 11:     printf("How many productions ? :"); 12:     scanf("%d",&count); 13:     printf("Enter %d productions epsilon= $ :\n\n",count); 14:     for(i=0;i<count;i++) 15:        scanf("%s%c",prodn[i],&ch); 16:        do 17:        { 18:        n=0; 19:        printf("Element :"); 20:        scanf("%c",&c); 21:        FIRST(c); 22:        printf("\n FIRST(%c)= { ",c); 23:        for(i=0;i<n;i++) 24:        printf("%c ",first[i]); 25:        printf("}\n"); 26:        getch(); 27:        printf("press 1 to continue : ");

How To Implement DFA in C Code

Image
Implementing DFA in C Program If You need the .Exe File i will provide it.. 1:  /*   2:  *PROGRAM NAME: DFA.C 3:  *AIM : TO IMPLEMENT DFA 4:  *DATE : 07/28/2011 5:  */ 6:  #include<stdio.h> 7:  //nt a[10],b[10]; 8:  char letters[10]; 9:  int letter_count,count,final; 10:  int final_states[5]; 11:  void DEFINE_DFA(); 12:  int MOVE_DFA(int,char); 13:  int dfa[10][10]; 14:  int main() 15:  {   16:     int s,i,accepted; 17:     char line[10]; 18:    printf("\t\tDFA SIMULATOR\n\t******************************\n"); 19:    DEFINE_DFA(); 20:    do 21:    { 22:    s=0; 23:    i=0; 24:    accepted=0; 25:    printf("\n\nEnter Input String.. "); 26:    scanf("%s",line); 27:    while(line[i]!='\0') 28:    if((s=MOVE_DFA(s,line[i++]))<0) 29:    break; 30:    for(i=0;i<final;i++) 31:    if(final_states[i]==s) 32:    accepted=1; 33:    (accepted)?printf("\a\n\tYES..!!!") : printf("\a\n\tNO...!

How to Implement Two - Pass Assembler in C / Assembler C Code

Image
Implement Two - Pass Assembler in C:- Source Code:-  PROGRAM NAME: ASSEMBLER.C  AIM: TO IMPLEMENT A TWO-PASS ASSEMBLER  INPUT: "input.txt"  OUTPUT: "inter.txt" , "output.txt"  DATE: 08/09/2011  #include<stdio.h>  #include<string.h>  void chk_label();  void chk_opcode();  void READ_LINE();  struct optab  {    char  code[10],objcode[10];  }myoptab[3]={            {"LDA","00"},            {"JMP","01"},            {"STA","02"}         };  struct symtab{            char symbol[10];            int addr;         }mysymtab[10];  int startaddr,locctr,symcount=0,length;  char line[20],label[8],opcode[8],operand[8],programname[10];          void PASS1()           {              FILE *input,*inter;                                input=fopen("input.txt","r");                            inter=fopen("inter.txt","w"