How do I write a program to indicate the traffic through the switch | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How do I write a program to indicate the traffic through the switch

h.w

25th Jan 2020, 4:54 PM
ahmed
12 Answers
+ 5
Kindly Show your attempt First.. thank you
25th Jan 2020, 4:56 PM
Scooby
Scooby - avatar
+ 4
i see you indicated this is h.w assuming that is homework... please show the community your attempt and the errors you end up with but please do not expect others to do your homework. https://www.sololearn.com/discuss/1316935/?ref=app
25th Jan 2020, 4:57 PM
BroFar
BroFar - avatar
+ 4
I don't know whether you have got to the following chapter. Passing this link in a hope you can learn or review it, and clear your doubts about `switch` statement. https://www.sololearn.com/learn/CPlusPlus/1618/
25th Jan 2020, 5:08 PM
Ipang
+ 3
or do you want to understand how your code works?
25th Jan 2020, 5:12 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 2
Hi! you want to say that this is a program to indicate the traffic through the switch??? this is most likely similar to a manual traffic light switching program...
25th Jan 2020, 5:06 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 2
When you do a send() or recv() of data over the network, you will get a field value within the function given by the OS as to how many bytes were sent or received. You can add up these numbers to see the total number of bytes sent/received by the device.
27th Jan 2020, 4:35 AM
Sonic
Sonic - avatar
+ 2
Sonic I wonder what language would be suitable for programming such devices? languages of the C family? this is from the field of microcontroller programming, isn't it?
27th Jan 2020, 7:05 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 2
Ярослав Вернигора(Yaroslav Vernigora) I believe that C and C++ are common languages here. It doesn't have to be microcontrollers but I think that network switches and routers would have such code.
27th Jan 2020, 10:43 PM
Sonic
Sonic - avatar
+ 1
#include <iostream> using namespace std; int main() { char z; cin>>z; if(z=='r') cout<<"stop"; else if(z=='y') cout<<"be ready"; else if(z=='g') cout<<"walk"; else cout<<"error"; return 0; }
25th Jan 2020, 4:59 PM
ahmed
+ 1
Does h.w. stand for homework or hardware?
27th Jan 2020, 4:32 AM
Sonic
Sonic - avatar
0
ok
25th Jan 2020, 4:58 PM
ahmed
0
My teacher did not explain the function of the switch
25th Jan 2020, 5:01 PM
ahmed