Problem :- Write A C++ Program Generate Truth Table Of X Y+C Using Loops
Logic :- 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 see this C++ Program For Draw A Perfect Christmas Tree
Solution :-
Output:-
Logic :- 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 see this C++ Program For Draw A Perfect Christmas Tree
Solution :-
#include<iostream>
using namespace std;
int main()
{
int a,b,c;
//By-Ghanendra badav
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:-
write a code for the input expression by the user.
ReplyDelete