   How many pictures calculator
  How do you work out how many pictures there are for a given number of pixels and colours?The image dimensions are 1 Bit Per Pixel  = 2 colours4*4 number of pixels = 16 pixelsI think the answer is2^16 = 65536 2 to power of 16 is 65536Is this the correct answer?   
  #include <iostream>#include <time.h>#include <stdio.h>using namespace std;FILE *output_log = NULL;const int numofbits=2;int current_pos=numofbits;const char target_num=122,start_num=97;char bits[numofbits];char result_bits[numofbits];clock_t ticks1;int string_length(char* string1){  int len=0;  while (1)  {    if (*string1==0)    {    break;    }    string1+=1;    len+=1;  }  return len;}void init_bits(){  int i=0;  for(i=0; i<=numofbits; i+=1)  {   bits=start_num;   result_bits=target_num;  }  output_log=fopen("c:\\output_log.txt","w");}void running(){  int i=0,found=0,total_count=0;  double clock_count=0;  //char string1[1];  while (1==1)  {    clock_count+=1;    if (clock_count>10000000)    {    //ticks1=clock();    total_count+=1;    cout << total_count << endl;    clock_count=0;    }    for(i=0; i<=numofbits; i+=1)    { char a; //sprintf(string1,"%d",bits); //fprintf(output_log,string1); a=bits; fprintf(output_log, &a );    }    fprintf(output_log,"\n");    found=1;    for(i=0; i<=numofbits; i+=1)    { if (bits != result_bits) {   found=0;   break; }    }    if (found==1)    { break;    }    //cout << current_pos << endl;    bits[current_pos]+=1;    if ( bits[current_pos] >target_num)    { bits[current_pos]=start_num; current_pos-=1; for (i=current_pos; i>=0; i-=1) {   bits+=1;   if (bits>target_num)   {bits=start_num;   }   else   {current_pos=numofbits;break;   } }    }  }}int main(){    init_bits();    //cout << "Hello world!" << endl;    running();    fclose(output_log);    return 0;};  Think abstract. Compare this situation to when you want to know how many states a binary number with n digits has: it would be 2digit-count. Or generally, you have base b and digit count d, then the number of states is n = bd.Take that formula, input the number of possible states per pixel, which is then your base, then your number of digits is the number of pixels:n = bd  = (2usable bit depth) width*heightSo in case of an 8bit image, which is 2*2 pixels big, you'd get:n = (2^8) ^ (2*2)  = 256 ^ 4  = 4294967296Which happens to be the same as an 4 byte integer (see the analogy? 4 pixels of 1 byte each can encode the same amount of information as a 4 byte integer, which is essentially 4 bytes coupled together).sidenote: would you mind enclosing your code into [ source ] tags? info;  gareth_mcdaid, you are correct.   