Monday, December 31, 2012

Last post of the year 2012

Hi to all the blog viewer's.

There were few posts this year, I am not sure weather they are interesting or not but I hope u like them...:)
Posts this year were not that frequent, I can promise this 2013 will have more frequent posts with interactive and interesting stuff.....;)

2012 posts were mostly TECHNICAL, which is not good right! ;) So this year will be a pack of music, treck's, sharing and then at last technical...

So goodbye to 2012..I here by welcome 2013 ...hiphip hurray
:)

Wednesday, June 6, 2012

Simplest logic for Time Display on LCD using 8051

/* here time starts from 0 seconds, you can add logic to set the time

not clear den try to make it clear or comment here */


#include reg51.h #include "lcd_display4bit.h" //for header check this void printTime(); long timerCount=; short int count=0; sbit getTime=P1^2; void CountSeconds() interrupt 1 {

Thursday, May 31, 2012

String Sorting Program in C (uses array of pointers to store strings)

/* string sorting program the logic may be simple but I have used array of pointers here to store the strings
crucial here is u should you malloc and calloc to get 
correct output(because array of pointers are used)*/ #include stdio.h #include string.h #define MAX 50 void main() { char *names[MAX],*dummy; int i=0,j=0,n=0; clrscr(); puts("enter no. of strings you want to enter"); scanf("%d",&n); printf("please enter %d strings\n\n",n);

Sunday, May 27, 2012

Scramble word finder- C program

/* C program for SCRAMBLE word finding
Download a wordlist.txt file on internet which consists of
all possible english words and save it in your program folder
before running the program. */


#include stdio.h #include string.h void main() { FILE *fp; char scramble[12],word[18],dummy[18],c; int i=0,j=0,wordLen,wordLenS,count=0; clrscr(); fp=fopen("wordlist.txt","r"); printf("enter scrambled word--"); scanf("%s",scramble); wordLenS=strlen(scramble);

Wednesday, May 16, 2012

Pattern Finder in all DIRECTIONS in a GRID of numbers -C program

/* Pattern Finder in all DIRECTIONS in a GRID of numbers -C program
you are allowed to enter a pattern of any length then the ROW and
COL of the pattern occurence is shown in the output.
pattern is searched in ALL THE EIGHT DIRECTIONS */


#include stdio.h #include string.h short int checkPattern(int,int,int); short cp[8][8]={5,4,1,2,3,4,5,6, 6,3,1,2,3,4,5,5, 5,7,5,3,5,1,3,1, 4,1,7,4,3,4,5,1, 3,2,3,4,5,1,5,2, 2,2,5,2,1,4,1,3, 1,4,7,8,6,5,4,4, 6,5,3,2,6,7,8,5}; char p[5]; void main() { int i,j,k;

Friday, May 11, 2012

Password STRENGTH and VALIDITY checking C program

/* password Strength and Validity checking C program-

This program takes your password and checks weather its valid
are not.
If valid then its checks the password strength and gives
one of the following result : LOW, MEDIUM, HIGH, VERY HIGH.


note-this is my algorithm(most followed), you can change as you need.
*/


#include stdio.h #include conio.h #include string.h #define SIZE 32 short int checkValid(char*); void checkStrength(char*); short int alphabetCount=0, digitCount=0; short int length=0; short int symbolCount=0; //to count symbols like ;'./ etc void main() { char pw[SIZE],c; short int count,error,i=0; clrscr();

Sunday, April 29, 2012

PASSWORD entry model- C program

// program for how **** are displayed when you type anything
// in the PASSWORD box


#include stdio.h #include conio.h int main() { int i=0; char ch,pass[10]; clrscr(); puts("enter password (max 10 characters wide) \n"); puts("only digits and characters are allowed "); puts("\n enter here- "); while((ch=getch())!='\r') //until ENTER is pressed { if(isalnum(ch)) { putchar('*'); pass[i++]=ch; } } pass[i]='\0'; printf("\n entered password is- %s",pass); getch(); return 0; }

Tuesday, April 24, 2012

RFID based Attendance system using 8051- with easy AUTOMATIC FILE generation facility


watch the video for explanation of the project

#include
 #include<string.h>
 #include "lcd_display4bit.h"

 #define TOTAL 5

 void serial_init();
 void serial_txS(char *);
 void serial_tx(char);
 void checkID();
 void printOnTerminal();
 short int checkTodaysAttd(int);

 sbit ON=P1^0;
 sbit RESET=P1^1;
 sbit result=P1^2;
 sbit IR_Tx=P1^3;
 sbit IR_Rx=P1^4;
 sbit Reset_Todays_Attendence=P1^5;
 
struct details
 {
   char *name;
   char id[4];
   int count;
 }emp[TOTAL]={{"phanindra", "437p", 0},
          {"nayak",     "455n", 0},
          {"anilKumar", "414a", 0},
          {"gowtham",   "456g", 0},
          {"chaitu",    "449c", 0}};

 char recieved_id[4]={0};
 int i, no_of_stu=0, todays_count=0;
 int todays_ids[4]={0};
 short int access=0, gotID=0;

 void serial() interrupt 4
 {
   EA=0;
     for(i=0;i<4;i++)
      {
        while(RI==0);
        recieved_id[i]=SBUF;
        RI=0;
      }
      gotID=1;
   EA=1;
 }

//***********************************------
 void main()
  {
    ON=RESET=result=1;
    rs=en=0;
    P2=0x00;
    IR_Rx=1;
    IR_Tx=0;
    EA=1;
    ES=1;
    serial_init();
    lcd_init();

super:    
   while(1)
     {
     IR_Tx=0;
     lcd_cmd(0x01);

       while(!ON)
       { 
        lcd_cmd(0x01);
        IR_Tx=1;
         while(!(IR_Rx==1))
         {
          lcd_cmd(0x01);
          lcd_dataS("ID please");
          
          while(gotID==0)   //wait until any card is shown
            if(ON==1) goto super;
          
          checkID();    
         }
       }
      /////////////////////////
       while(!result)
        {
          for(i=0;i<=TOTAL;i++)
          {
            lcd_cmd(0x01);
            lcd_dataS(emp[i].name);
            lcd_cmd(0xc0);
            lcd_data_int(emp[i].count);
            delay_msec(500);
          }
        }
      ////////////////////////

       while(! Reset_Todays_Attendence)
        {
          for(i=0;i'\0';

          todays_count=0;
          lcd_cmd(0x01);
          lcd_dataS("todays attd rst");
          delay_msec(100);
        }
      ///////////////////////
      }    //end of super loop
 } //end of main

//*************************************

void checkID()
{
  access=0;               //like a flag
  lcd_dataS(recieved_id);
    for(i=0;iif(( strcmp(emp[i].id , recieved_id) )==0)
     { 
      if(checkTodaysAttd(i)) 
          {
              access=1;
              lcd_cmd(0x01);
              lcd_dataS("welcome");
              lcd_cmd(0xc0);
              lcd_dataS(emp[i].name);
              emp[i].count++;

            todays_ids[todays_count]=i+1;
                 todays_count++;

            delay_msec(400);
              printOnTerminal();
            gotID=0;
              break;
          }
       else
         {
           lcd_cmd(0x01);
           lcd_dataS("your turns over");
           gotID=0;
           delay_msec(400);
         }
     }
    }


   if(access==0)
    {
        lcd_cmd(0x01);
        lcd_dataS("access denied");
        delay_msec(100);
        gotID=0;
    }    
}

short int checkTodaysAttd(int id)
{
  short int d;
  for(d=0;dif(id==(todays_ids[d]-1))
    return 0;    //return 0 if specific ID has already been
  }               //counted for today.
  return 1;
}

void printOnTerminal()
{ EA=0;
  serial_tx('\r');
  serial_tx('\n');
  serial_txS(emp[i].name);
  serial_tx(' ');
  serial_txS(emp[i].id);
  serial_tx(' ');
  serial_tx(emp[i].count+48);
  EA=1;
}  

void serial_init()
{
  TMOD=0x20;
  TH1=0xfd;
  SCON=0x50;
  TR1=1;
}

void serial_txS(char *p)
{
  while((*p)!='\0')
  {
    SBUF=*p;
    while(TI==0);
    TI=0;
    p++;
  }
}

void serial_tx(char x)
{
  SBUF=x;
  while(TI==0);
  TI=0;
} 

Thursday, April 5, 2012

Searching WORD and its COUNT in a FILE - C program


string Searching in a FILE- C program
count of the appearances 
/* program for searching a keyword in a FILE.
   program also tells the number of matches */


 #include "stdio.h"  
 #include "string.h"
 #include "ctype.h"

 void main()
 {
   FILE *fp;
   char keyword[15]={0},c;
   int i,length,count=0;
   clrscr();

Thursday, March 8, 2012

Time Display On LCD using 8051 Microcontroller

/* Displaying time on LCD using microcontroller
    To get 1sec delay timer(16bit mode) should overflow 14 times, 
 but instead i have used only 11 times because I 
 have counted prograam instructions delays and 11 
 times will increment exactly 1sec.   

 algorithm: wait in the loop for INCREMENT to be 1
      INCREMENT will be 1 only when the timer0
      overflows for 11 times(spcifically for my program)
      see my program logic, you can understand  */


#include<reg51.h>
#include "lcd_display4bit.h"

sbit ON=P1^0;
sbit SET=P1^1;
sbit incr_hrs=P1^2;
sbit incr_min=P1^3;
sbit set_hrs=P1^5;
sbit set_min=P1^4;

int sec,min,hrs;
int min_value=0,hrs_value=0,sec_value=0;
int count=0,increment=0;

void timer0() interrupt 1
{

  EA=0;
   TH0=0x00;
   TL0=0x00;
   count++;       //everytime timer overflows count is incremented
   if(count==11)  //if count is 11 then make increment=1
    {             //why 11 because if timer overflows for 11 times  
     count=0;     //then it will be 1sec
     increment=1;
    }
 else 
  increment=0;
  TF0=0;
  EA=1;
}

Wednesday, March 7, 2012

LCD in 4bit MODE -8051



/* LCD 4bit MODE-  D7-D4 of LCD are connected to P2.7-P2.4

   ALGORITHM- first higher byte is sent and then the lower byte
          
     step1: mask the Lower nibble and send them to LCD 
               (temp= value & 0xf0);
          send(temp);
     step2: enable pulse
     step3: left shift the value for 4 times, which makes lower nibble
            moves to higher nibble and higher nibble moves to lower nibble
          temp= value<<4;
       temp=value & 0xf0;
       send(temp);
     step4: enable pulse      */


#include<reg51.h>

void delay_msec(int);
void lcd_init();
void lcd_data(char);
void send(char);
void lcd_cmd(char);
void lcd_dataS(char *p);
void lcd_data_int(int);

sbit rs=P2^0;
sbit en=P2^1;

//***********************************------
void main()
{
  P2=0x00;
  rs=en=0;
  lcd_init();
  lcd_dataS("hello pc");
  lcd_cmd(0xc0);
  lcd_data_int(555);
  while(1)
  {
  }
}

//*************************************

Saturday, March 3, 2012

Calculator Project with just keypad and LCD 8051

/* calculator Project for 8051---
   Possible Operation- add, sub, mul, div
   limitations- decimal part is truncated
                result upto only 6decimals */
/* algorithm::
     step1:store the entered values in an array
         if any operator key is pressed goto step2
  step2:store the var1 here (using convertArrayToDecimal() function)
        and also store the operator pressed
         if '=' operator is pressed goto step3
  step3:do the respective operation and display the result */
#include<reg51.h>
#include"lcd_display.h"

int pow(int, int);
void convertArrayToDecimal(int*);
void clear_array();
void column1();
void column2();
void column3();
void column4();
char getkey();

sbit c1=P2^0;
sbit c2=P2^1;
sbit c3=P2^2;
sbit c4=P2^3;
sbit r1=P2^4;
sbit r2=P2^5;
sbit r3=P2^6;
sbit r4=P2^7;


int var1=0,var2=0,dummy_var,row,col;

char values[4][4]={{55,56,57,'/'},
                   {52,53,54,'*'},
          {49,50,51,'-'},
          {' ',48,'=','+'}};

int num[5]; // to store the entered keys
int i=0;
void main()
{
char key;
unsigned char operation;
int var_count=0;
int result;

Thursday, March 1, 2012

Security Door project Program for 8051


#include<reg51.h>
#include"lcd_display.h"

void column1();
void column2();
void column3();
void resetPassword();
void getNewPassword();
char getkey();

sbit c1=P0^0;
sbit c2=P0^1;
sbit c3=P0^2;
sbit r1=P0^3;
sbit r2=P0^4;
sbit r3=P0^5;
sbit r4=P0^6;
sbit reset_password=P1^2;
sbit ON=P1^3;

char reset_code[3]={'9','9','9'},password[6];

int i=0,count=0,danger=0;
int col,row;
char num[4][3]={{'1','2','3'},
                {'4','5','6'},
       {'7','8','9'},
       {'*','0','#'}};

void main()
{
  char c;
  c1=c2=c2=1;
  r1=r2=r3=r4=0;
  reset_password=ON=1;
  rs=en=0;
  P2=0x00;
  TMOD=0x01;
  lcd_init();
 

Saturday, February 25, 2012

Keypad Interfacing with 8051 Program


#include<reg51.h>

void lcd_cmd(char);
void lcd_init();
void lcd_data(char);
void delay(int);

sbit rs=P2^0;
sbit oe=P2^1;

void column1();
void column2();
void column3();
char getkey();

sbit c1=P1^0;
sbit c2=P1^1;
sbit c3=P2^2;
sbit r1=P2^3;
sbit r2=P2^4;
sbit r3=P2^5;
sbit r4=P2^6;

int x,y;
char num[4][3]={{'1','2','3'},
                {'4','5','6'},
       {'7','8','9'},
       {'*','0','#'}};
void main()
{
char c;

Token System Program for 8051


#include<reg51.h>

void lcd_cmd(char);
void lcd_init();
void lcd_data(char[]);
void delay(int);
void lcd_dataint(int);

void counter1();  //to print the count value at counter1 location
void counter2();                                     //(on lcd)
void counter3();

sbit rs=P2^4;
sbit oe=P2^0;
sbit but1=P2^1;   //counter1 button 
sbit but2=P2^2;   //counter2 button
sbit but3=P2^3;   //counter3 button

int token_no=0;   //overall count 

void main()
{
   rs=0;
   oe=0;
   but1=1;but2=1;but3=1;
   TMOD=0x01;
   lcd_init();
   lcd_data("C1    C2    C3  ");

Simple ELEVATOR program for 8051



#include<reg51.h>
#include"lcd_display.h"

sbit ON = P1^0;
sbit floor1 = P1^1;
sbit floor2 = P1^2;
sbit floor3 = P1^3;
sbit dooropen = P1^4;

sbit motorF = P2^0;
sbit motorR = P2^1;
sbit motor_en = P2^3;
sbit led_doorOpen = P2^2;
sbit ON_led = P2^4;

void delay_sec(int);

short int PresentLevel = 0, RequestLevel;


void main()
{
motorF = motorR = led_doorOpen = motor_en = ON_led = rs = en = 0;
ON = floor1 = floor2 = floor3 = dooropen = 1;



TMOD = 0x01;
P3=0x00;
lcd_init();
motor_en=0;

Friday, February 24, 2012

Wired ROBO car Program for 8051

/* wired robo car program for 8051 microcontroller
 design description:;: contains two motors one on left(ml) and one on right(mr)::contains headlights and backlights::moreover this is wired robo car (not wireless) */
#include<reg51.h>

sbit mr_p = P2^0;      //motor_right_positive
sbit mr_n = P2^1;      //motor_right_negetive
sbit ml_p = P2^2;      //motor_left_positive 
sbit ml_n = P2^3;      //motor_left_negetive
sbit leds_front = P2^4;
sbit en_mr = P2^6;     //motor_right_enable
sbit en_ml = P2^7;     //motor_left_enable
sbit led_backL = P3^0;
sbit led_backR = P3^1;

sbit head_lights = P1^6;    //inputs
sbit key = P1^5;
sbit fw = P1^0;
sbit re = P1^1;
sbit left = P1^2;
sbit right = P1^3;
sbit stop = P1^4;

void main()
{
  int i;  

  fw = re = left = right = stop = head_lights = key = 1;
  mr_p = mr_n = ml_p = ml_n = leds_front = en_mr = en_ml = 0;
  led_backL = led_backR = 0;
  

Electronic Voting Machine


#include<reg51.h>


void nominee(char[],int);

void lcd_cmd(char);
void lcd_init();
void lcd_data(char[]);
void delay(int);
void lcd_dataint(int);
void results();

sbit start=P1^0;
sbit n1=P1^1;
sbit n2=P1^2;
sbit n3=P1^3;
sbit rs=P2^0;
sbit oe=P2^1;
sbit again=P1^4;
sbit result=P1^5;

int nom[3]={0,0,0};
int overallC=0,permission=0;

     
  void main()
   {
     n1=n2=n3=start=1;
     oe=rs=0;
     P3=0x00;
     TMOD=0x01;

Tuesday, January 10, 2012

understanding getch(), getche() and getchar() in C

/* program to understand the getch(), getche() and getchar() differences */

//note that these three functions are for getting character from the cosole only but they differ the way they take

#include<stdio.h>
#include<conio.h>
void main()
{
char ch[2],op;
int i=0;
clrscr();
while((i++)<=2)      //just i am rotating this for 3 times
{
printf("\na.getch() \nb. getche() \nc.getchar()\n\t");
puts("enter your option");
ch=getche();

switch(op)
{
case 'a': puts("\nenter char");
ch[0]=getch();      //here character entered is stored but not displayed on console
break;                                             
case 'b':puts("\nenter char");      
ch[1]=getche();   //here char entered is taken(no need to press enter) and displayed on console
break;                                          
case 'c': puts("\nenter char");
ch[2]=getchar();           //here character entered is displayed on console and
break;                           //entered char is stored only after pressing 'enter key'

}
}
printf("\nstored values are %s",ch);
getch();
}

Monday, January 9, 2012

C program for Decoding an Encoded file

/*program to decode an encoded file and storing decoded data into an another file */

#include<stdio.h>
void main()
{
int d,i;
char c;
FILE *fp1,*fp2;
clrscr();
fp1=fopen("resume_e.txt","r");           //open same encoded file in previous post
fp2=fopen("dec_resume.txt","w");

while((c=fgetc(fp1))!=EOF)      
{
d=c;
d=d-30;                     //here you should use the same value ie., in the previous
c=d;                            //post I used d=d+30 so here i should use d=d-30;
fputc(c,fp2);
puts("processing...");              
}
clrscr();
fclose(fp1);
fclose(fp2);
puts("decoding is over");
getch();
}

 

Encoding an Text file using C program

/* program to encode an text file */

#include<stdio.h>
#include<string.h>

void main()
{
int d,i;
char c;
FILE *fp1,*fp2;
fp1=fopen("resume.txt","r");         //here i used my resume file, you can use any file but it
fp2=fopen("resume_e.txt","w");  // should be in the BIN folder

while((c=fgetc(fp1))!=EOF)      //main logic
{
d=c;
d=d+30;
c=d;
fputc(c,fp2);
puts("processing...");                 //check by keeping this line before the loop
}
clrscr();
fclose(fp1);
fclose(fp2);
printf("text is encoded and stored in file");
getch();
}

Encoding text using C and storing in FILE

/* program for encoding the text and storing the original and encoded data in files */

#include<stdio.h>
#include<string.h>
void main()
{
char c, data[100], enc[100],enc_bin[8];
int d,i,j;
FILE *fp1,*fp2;
clrscr();
fp1=fopen("original.txt","w");
fp2=fopen("encoded.txt","w");
printf("enter text and press enter --\n\n\t");
i=0;
j=0;

while((c=getchar())!='\n')    //main logic
{
data[i++]=c;
fputc(c,fp1);             //storing the original data in file
d=c;                                //converting char to int (ascii value)
d=d+26;                      // changing its ASCII value by adding 26
c=d;                               // converting back it to char type
fputc(c,fp2);          //putting the encoded text into anotherfile
enc[j++]=c;
}

printf("encoded data is--\n\n\t ");
for(i=0;i<j;i++)
printf("%c",enc[i]);

fclose(fp1);
fclose(fp2);

getch();
}

Encoding text (basic encoding)

/* program for encoding entered text to any symbol (within the ASCII range)*/

#include<stdio.h>
#include<string.h>
void main()
{
char src[100]={0},enc[100]={0},c;
int i=0,d,len;
clrscr();
printf("enter text which you want to encode--");

while((c=getchar())!='\n')        //storing the entered text
 src[i++]=c; 

i=0;                                                                                                        len=strlen(src);

while(i<len)                  //main logic
{
d=src[i];
d=d+13;                      //instead of 13 you can take any value,
c=d;                              // but sum should be <255 because ASCii
enc[i]=c;                  //maximum value is 255
i++;
}

printf("encoded data is :\n\n\t %s",enc);

getch();
}

Converting text to Binary

#include<stdio.h>
#include<string.h>
void main()
{
int d,i=0,j=0,bin[8]={0};
char list[20],c;
clrscr();
printf("enter text press enter at last-");


while((c=getchar())!='\n')        //storing text into array using getchar()
list[i++]=c;


i=0;


while(i<strlen(list))                    //logic starts here
{
d=list[i];                                              // storing character in an dummy var.
j=0;
while(d>=1)                                      // binary conversion logic starts from here
{
if(d==1)
{
bin[j]=1;
break;
}
bin[j]=d%2;
d=d/2;
j++;
}                         


for(j=7;j>=0;j--)                          //this loop is for printing the binary form
printf("%d",bin[j]);
printf("\n");
i++;
}


getch();
}


Friday, January 6, 2012

Conversion of TEXT to BINARY

#include<stdio.h>
#include<string.h>
void main()
{
int d,i=0,j=0,bin[8]={0};
char list[20],c;
clrscr();
printf("enter text press enter at last-");
while((c=getchar())!='n')
list[i++]=c;

i=0;


while(i<strlen(list))
{
d=list[i];
j=0;
while(d>=1)
{
if(d==1)
{
bin[j]=1;
break;
}
bin[j]=d%2;
d=d/2;
j++;
}


for(j=7;j>=0;j--)
printf("%d",bin[j]);
printf("n");
i++;
}


getch();
}

Wednesday, January 4, 2012

Hello world!

Welcome to WordPress.com. After you read this, you should delete and write your own post, with a new title above. Or hit Add New on the left (of the admin dashboard) to start a fresh post.

Here are some suggestions for your first post.

  1. You can find new ideas for what to blog about by reading the Daily Post.

  2. Add PressThis to your browser. It creates a new blog post for you about any interesting  page you read on the web.

  3. Make some changes to this page, and then hit preview on the right. You can always preview any post or edit it before you share it to the world.

Monday, January 2, 2012

ASCII values printing on CONSOLE

/*program for printing ASCII values*/

#include

void main()
{
int x;
char p;
clrscr();
printf("ASCII values\n");
x=1;
while(x<=255)
{
printf("%d--%c\t",x,x);
x++;
}

getch();
}

ASCII values printing on CONSOLE

/*program for printing ASCII values*/

#include

void main()
{
int x;
char p;
clrscr();
printf("ASCII values\n");
x=1;
while(x<=255)
{
printf("%d--%c\t",x,x);
x++;
}

getch();
}

DECIMAL to BINARY conversion (for a range of decimal values)

/* C program for DECIMAL TO BINARY CONVERSION for a range of values */


#include
void main()
{
int num,i=0,start,end,j;
int bin[10]={0};
clrscr();
printf(" decimal to binary converting\n\n\n");
printf("enter START and END of range: "); //suppose if range is 1to50, then you
scanf("%d%d", &start,&end); //should enter START=1 and END=50
printf("\n\n\t the binary form is :\n\n");
for(num=start;num<=end;num++)
{
i=0;
j=num;
while(j>=1)
{
if(j==1)
{
bin[i]=1;
break;
}
bin[i]=j%2;
j=j/2;
i++;
}

printf("%4d -- ",num);
for(i=9;i>=0;i--)printf("%d",bin[i]);
printf("\n");
}

getch();
}

DECIMAL to BINARY conversion (for a range of decimal values)

/* C program for DECIMAL TO BINARY CONVERSION for a range of values */


#include
void main()
{
int num,i=0,start,end,j;
int bin[10]={0};
clrscr();
printf(" decimal to binary converting\n\n\n");
printf("enter START and END of range: "); //suppose if range is 1to50, then you
scanf("%d%d", &start,&end); //should enter START=1 and END=50
printf("\n\n\t the binary form is :\n\n");
for(num=start;num<=end;num++)
{
i=0;
j=num;
while(j>=1)
{
if(j==1)
{
bin[i]=1;
break;
}
bin[i]=j%2;
j=j/2;
i++;
}

printf("%4d -- ",num);
for(i=9;i>=0;i--)printf("%d",bin[i]);
printf("\n");
}

getch();
}

C program for DECIMAL to BINARY conversion

/* program for DECIMAL to BINARY converter */

#include
void main()
{
int num,i=0,bin,next;
clrscr();
printf(" decimal to binary converting\n\n\n");
printf("enter any decimal no. ");
scanf("%d", &num);
printf("please note that the binary form is represented in the\n form
(LSB ...MSB)\n");
printf("\n\n\t The binary form is :");


while(num>=2)
{
bin=num%2;
num=num/2;
printf("%d",bin); //logic can easily implemented using ARRAYs
if(num==1) //but i am not using arrays here.
printf("1"); //this is the MSB
}

getch();
}

C program for DECIMAL to BINARY conversion

/* program for DECIMAL to BINARY converter */

#include
void main()
{
int num,i=0,bin,next;
clrscr();
printf(" decimal to binary converting\n\n\n");
printf("enter any decimal no. ");
scanf("%d", &num);
printf("please note that the binary form is represented in the\n form
(LSB ...MSB)\n");
printf("\n\n\t The binary form is :");


while(num>=2)
{
bin=num%2;
num=num/2;
printf("%d",bin); //logic can easily implemented using ARRAYs
if(num==1) //but i am not using arrays here.
printf("1"); //this is the MSB
}

getch();
}