convert digits into letters

hello guys i am trying to convert my 1 into 't' and my 0 into 'f' but so far no luck. Any help will be appreciated. It is a basic truth table. Thank you. Here is the code

#include <string>
using namespace std;
int main()
{
int a,b,c,d,e,f,g,h,i,j,k,l,m;

cout<<"Number 1 refers to True, 0 to False \n\n\nl | m | ~l | ~m | l&&m | l||m | l^m | l^m^m | l^m^l | ~(l&m) | ~l||~m | ~(l||m) | ~l&~m | \n\n"<<endl;

for (l = 1; l >= 0; l--)

for (m = 1; m >= 0; m--){

if ((l == m) || (l = !m) || (!l == m) || (!l == !m))

a = !l, b = !m, c = l&&m, d = m || l, e = l^m, f = l^m^m, g = l^m^l, h = !(l&&m), i = !l || !m, j = !l && !m; k = !(l||m);

cout <<l<<" "<< m<<" "<<a<< " "<<b<< " " <<c<< " "<<d<< " "<<e<< " "<<f<< " "<<g<< " "<<h<< " "<<i<< " "<<k<< " " <<j<<"\n\n"<< endl;
}
system("pause");
return 0;
}
you need brackets after your for and if statements.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <iomanip>

int main()
{
    // convert true to 'T' and false to 'F'
    // http://www.stroustrup.com/C++11FAQ.html#lambda
    const auto to_char = [] ( bool v ) { return v ? 'T' : 'F' ; } ;

    static const auto w6 = std::setw(6) ;
    std::cout << w6 << 'a' << w6 << 'b' << w6 << "!a" << w6 << "!b" << w6 << "a&&b"
              << w6 << "a||b" << std::setw(10) << "a xor b "
              << "\n------------------------------------------------\n\n" ;

    for( bool a : { true, false } ) // http://www.stroustrup.com/C++11FAQ.html#for 
    {
        for( bool b : { true, false } )
        {
            std::cout << w6 << to_char(a) << w6 << to_char(b) << w6 << to_char(!a)
                      << w6 << to_char(!b) << std::setw(5) << to_char(a&&b)
                      << w6 << to_char(a||b) << std::setw(7) << to_char(a!=b) << "\n\n" ;
        }
    }
}

http://coliru.stacked-crooked.com/a/de2ab6b1d909665e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

int main()
{
   const int width = 10;
   #define W << setw( width ) <<
   char T[] = { 'F', 'T' };

      cout W   "A"  W   "B"  W   "!A"  W   "!B"  W  "A&&B"   W  "A||B"  W   "A^B"   W  "!(A&&B)"  W   "!A||!B"  W  "!(A||B)"   W   "!A&&!B" << endl;
      cout << string( 11 * width, '-' ) << endl;

   for ( int i = 3; i >= 0; i-- )
   {
      bool A = i & 2, B = i & 1;
      cout W  T[A]  W  T[B]  W  T[!A]  W  T[!B]  W  T[A&&B]  W T[A||B]  W  T[A!=B]  W  T[!(A&&B)] W  T[!A||!B]  W  T[!(A||B)]  W  T[!A&&!B] << endl;
   }
} 

         A         B        !A        !B      A&&B      A||B       A^B   !(A&&B)    !A||!B   !(A||B)    !A&&!B
--------------------------------------------------------------------------------------------------------------
         T         T         F         F         T         T         F         F         F         F         F
         T         F         F         T         F         T         T         T         T         F         F
         F         T         T         F         F         T         T         T         T         F         F
         F         F         T         T         F         F         F         T         T         T         T
thanks!
Topic archived. No new replies allowed.