11/14/2015

C++ Program Generate Truth Table Of X Y+C Using Loops

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 :-

#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:-

C++ Program Generate Truth Table Of  X Y+C Using Loops

Ghanendra Yadav

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

No comments:

Post a Comment