Need your kind expert advice. I have to come out with a programme in C++ but I have no idea how to make it, really hope that anyone of you here can help me. the output is suppose to be as below. Pls guide me, experts. Thanks.
Led Pattern: 0 0 0 0 0 0 0 1
Enter logic states of sw1 and sw0, separated by a space: 0 1
Led Pattern: 1 0 0 0 0 0 0 0
Enter logic states of sw1 and sw0, separated by a space: 0 1
Led Pattern: 0 1 0 0 0 0 0 0
Enter logic states of sw1 and sw0, separated by a space: 0 1
Led Pattern: 0 0 1 0 0 0 0 0
Enter logic states of sw1 and sw0, separated by a space: 1 0
Led Pattern: 0 1 0 0 0 0 0 0
Enter logic states of sw1 and sw0, separated by a space: 1 0
Led Pattern: 1 0 0 0 0 0 0 0
I need to create 3 classes....switch class...led class...circuit class
To the right and to the right?
OK, clarify even further. Give me the whole damn homework assignment because your descriptions so far are crap. I'll grin and bear it because I can't figure this out.
Looks like a shift operation to me. From from I can tell, if the first bit is 0, the bits are shifted to the right, otherwise they're shifted to the left. AFAICT, the second bit is meaningless.
tummychow: If you can't understand, don't complain that it's not clearly explained. The explanation is incomplete, true, but it's not unintelligible. After all, I could figure it out, and I understand what "11" means.
the 00 input will also have no change from the previous pattern
tummychow: apology if i have confuse you. i just need help...nothing more than that..appreciate if u can help with the source code. i may not be able to further explain till some qns relate to me...appreciate for your understanding
// example of bitshifting
#include <iostream>
usingnamespace std;
void show_binary(unsignedint u);
int main()
{
int i=1, t;
// shift left
for (t=0;t<8;t++) {
show_binary(i);
i = i << 1;
}
cout << "\n";
// shift right
for (t=0;t<8;t++) {
i = i >> 1;
show_binary(i);
}
return 0;
}
// DIsplay the bits within a byte.
void show_binary(unsignedint u)
{
int t;
for(t=128;t>0;t=t/2)
if(u & t) cout << "1 ";
else cout << "0 ";
cout << "\n";
}