The simplest way to do so would be using binary code.
We will simply write the binary codes for all numbers from 0 to the maximum number we can make using the number of binary digits equal to the input.
Say, we input 3.
The maximum number we can make using 3 binary digits, is 111 i.e. 7.
So we will write binary code for all number from 0 to 7.
Which are:
000=0
001=1
010=2
011=3
100=4
101=5
110=6
111=7
To write T or F, we will simply put a condition where T is printed for 1 and F for 0.
Here is the code:
#include<stdio.h>
#include<string.h>
int num_of_digits;
void bitcode(int num){
int current_digit_num=num_of_digits;
while(current_digit_num!=0){
if(num%2==1)
printf("T ");
else
printf("F ");
num=num/2;
current_digit_num--;
}
}
main()
{
int current_num,value;
scanf("%d", &num_of_digits);
value=pow(2,num_of_digits);
for(current_num=0;current_num<value;current_num++){
bitcode(current_num);
printf("\n");
}
return 0;
}
NOTE: This method works because from 0 (000..) to the maximum number (111..), we go through all the possible combinations we can make to fill that much number of digits with 0 or 1.