C++ Code Examples



Q: Write a short code using C++ to print out all odd number from 1 to 100 using a for loop(Asked by Intacct.com people)

for( unsigned int i = 1; i < = 100; i++ )    if( i & 0x00000001 )        cout << i<<",";

Q:ISO layers and what layer is the IP operated from?( Asked by Cisco system people)

Aapplication, Presentation, Session, Transport, Network, Data link and Physical. The IP is operated in the Network layer.


Q: Write a program that ask for user input from 5 to 9 then calculate the average( Asked by Cisco system people)


A.int main()
{
int MAX=4;
int total =0;
int average=0;
int numb;
cout<<"Please enter your input from 5 to 9"; cin>>numb;
if((numb <5)&&(numb>9))
cout<<"please re type your input"; else for(i=0;i<=MAX; i++) { total = total + numb; average= total /MAX; } cout<<"The average number is"<<

return 0;
}


Q: Can you be bale to identify between Straight- through and Cross- over cable wiring? and in what case do you use Straight- through and Cross-over? (Asked by Cisco system people)

A. Straight-through is type of wiring that is one to to one connection Cross- over is type of wiring which those wires are got switched

We use Straight-through cable when we connect between NIC Adapter and Hub. Using Cross-over cable when connect between two NIC Adapters or sometime between two hubs.


Q: If you hear the CPU fan is running and the monitor power is still on, but you did not see any thing show up in the monitor screen. What would you do to find out what is going wrong? (Asked by WNI people)


A. I would use the ping command to check whether the machine is still alive(connect to the network) or it is dead.


courtesy:http://www.crackthecampus.com

No comments:

Post a Comment