Sunday, November 29, 2015

Code Snippets


#include <stdio.h>
#include <math.h>

int main(){

  printf("\n");
 
  if(0) {
 
  //Divide by 2
          int i = 1024;
          while(i>0){
                  printf("%d,", i);
                i >>= 1;
          }
          printf("\b ");   

  } else {
 
    //Multiply by 2
          int j = 0;
          for(j=0; j < 10; j++){
              //printf("%d,", (int)pow(2, j));
             
              printf("%d,", 1 << j);

          }
          printf("\b ");   
  }
  printf("\n\n");

  return 0;
}

No comments: