belongs to collection: Loop Programs In C ++Programming
Write A C++ Program Generate Truth Table Of X Y+C Using LoopsLogic :-
We need three loop initialize with zero and limit is 1 ,and use a formula to print a*b+c==2 .if you are facing problem to getting three loops
#include<iostream> using namespace std; int main() { int a,b,c; cout<<"Truth Table Of AB+C\t"; for(a=0;a<=1;++a) { for(b=0;b<=1;++b) { for(c=0;c<=1;++c) { if(a*b+c==2) cout<<"\n"<<a<<"\t"<<b<<"\t"<<c<<"\t1"; else cout<<"\n"<<a<<"\t"<<b<<"\t"<<c<<"\t"<<a*b+c<<endl; } } } cout<<"\n\n"; return 0; }
Output:
Truth Table Of AB+C
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 1
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Output:
Truth Table Of AB+C
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 1
need an explanation for this answer? contact us directly to get an explanation for this answer