#include #include #include #define MAXINT 65536 #define SIZE 100 int arr[SIZE][SIZE]; // a global array , to contain table information int ele=0,ind=0; // indices to be used in above array void summ(int i); int isPow2(int i) { /*if input no is power of two retrun 1 , else 0*/ if(MAXINT % i==0) return 1; //true return 0; //false } int calcPow(int i) { /*Thism ethod returns , what is power of 2 , in a no. which is of form 2 to the power p */ /* return p , from input of format 2^p */ int count=-1; /* validate */ if(!isPow2(i)) printf("flow error..."); else while(i>0) { i/=2; count++; } return count; } int findLowerOf2(int i) { /*a function to calculate the no , JUST below i , which is power of 2 */ int count=-1; if(isPow2(i)) return pow(2,i); else while(i>0) { i/=2; count++; } return pow(2,count); } void callSumm(int i) { /* A method to call summ() method , with assertion that all global parameters are incremented at each call to summ() */ ind=0; summ(i); arr[ele][ind++]=-1; ele++; } void dieError() { /* If failure , exit the program*/ //exit(1); } int howManyTimes(int val,int a[]) { /* a method to check that how many times no val is occuring in array a[] */ int i,count=0; for(i=0;a[i]!=-1;i++) if(a[i]==val) count++; return count; } void checkInput(int argc,char str[]) { int i=0; if (argc<2) { printf("usage: filename.o 'The code string' "); printf(" ex. \n a.out 110110 \n"); dieError(); } for(i=0;i