Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  bin.l
Language: C/C++
Code:

%{ 
  #include<stdio.h> 
  int num, rem, binary=0, place=1; 
%} 
  
%% 
[0-9]+   { num=atoi(yytext); 
             while (num > 0) 
             { 
              rem= num % 2; 
              binary+= rem*place; 
              place*= 10; 
              num/= 2; 
             } 
              printf("%d", binary); 
          }
%% 
  
int main() 

    yylex(); 
    return 0; 

          
Comments: