10.02.2011

Program binary numbers

Binary numbers :
0 1 2 4 8 16 32 64 128 256.......n


/*c program to print binary numbers series*/
#include<stdio.h>
#include<conio.h>
int main()
{
 int x,y,z,num;
 printf("Enter last number where goes to end binary numbers : ");
 scanf("%d",&num);
 x=0;
 y=1;
 while(num>=x)
 {
   z=x+y;
   printf("%d\t",x);
   y=z;
   x=y;
 }
 getch();
 return 0;
}

/***************Output*****************
Enter last number where goes to end binary numbers : 50
0 1 2 4 8 16 32


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

No comments:

Post a Comment