Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  a.l
Language: C/C++
Code:
%{ 
/* Definition section */
#include<stdio.h> 
int i,n,x=0,a; 
%} 

DIGIT [0-9] 

%% 
{DIGIT}+ { n=atoi(yytext); 
     
               for(i=0;n!=0;++i)
               {
                    a=n%10;
                    x=(a)*(pow(2,i))+x;
                    n=n/10;
               }
               printf("%ld",x);
.|n ECHO; 
          
%% 
 
int main() 

     yylex(); 
     return 0; 
}      

          
Comments: