Monday, 17 November 2014

Cigarette Smokers problem- solution

Three smokers are sitting at a table. One of them has tobacco, another has cigarette papers, and the
third one has matches -- each one has a different ingredient required to make and smoke a cigarette but he may not give any ingredient to another. On the table in front of them, two of the three ingredients will be placed, and the smoker who has the necessary third ingredient should pick up the ingredients from the table, make a cigarette and smoke it. Since a new set of ingredients will not be placed on the table until this action is completed, the other smokers who cannot make and smoke a cigarette with the ingredients on the table must not interfere with the fellow who can. Therefore,
coordination is needed among the smokers. 

Tuesday, 12 August 2014

Develop GUI apps within minutes with Gambas IDE

 For Ubuntu, open your terminal and type the following commands one by one:

sudo add-apt-repository ppa:nemh/gambas3
sudo apt-get update
sudo apt-get install gambas3


useful link

wxPhyton Totorial: Useful for developing GUI for LINUX

http://zetcode.com/wxpython/

Tuesday, 11 February 2014

Yacc programming in windows

download required software : click here

write a yacc program and save it as prg1.y:

%{
// yacc program to implement the grammar
/*
S->(S)
  |a
*/    
#include <stdio.h>
#include <stdlib.h>
%}

%%
Stmt1 : Stmt1 '\n' {   printf ("\n.. Valid Expression.. \n");
                               exit(0);  }
         | S
         | error  {  printf ("\n..Invalid ..\n");
                        exit(0); }
         ;
S : '(' S ')'
   | 'a'
  ;
%%

main ( )
{
  printf("Enter a string to validate : ");
  yyparse ( );
}

yylex()
{    int ch;            
      while(ch=getchar())  
      return ch;      
}
         
yyerror(char *s)
{
    printf( "%s", s );
}

compile the program using the command: bison prg1.y


with this command a C program is created in the current folder with name prg1.tab.c
now compile and run the C program: