Showing posts with label Virtual University of Pakistan. Show all posts
Showing posts with label Virtual University of Pakistan. Show all posts

Tuesday, 18 November 2014

CS601 Assignment1

Question No.1 (10 Marks)
Let us consider a computer network in which each computer has number of I/O ports equal to 8. In this network every device has dedicated point to point link to every other device. You are required to fill in the following table with correct

Solution:
Number of Computers= Number of Ports+1=8+1=9
Number of Links= s(s-1)=9(9-1)/2=36







Question No. 2 (5 Marks)
Write the correct Transmission Mode for each of the following hardware devices in the given table?
Solution
Mouse.......................................................Simplex
Scanner......................................................Simplex
Walkie-Talkie.............................................Half Duplex
Telephone...................................................Full Duplex
Fax Machine...............................................Half Duplex

cs201 Assignment 1

A Game Generates Random Secret Number from given Range

Analysis of The Game:-

 This is a cute random number generation game. We have following terms for the game.
  1. The user gives the input to the game in the form of random numbers i.e Lower Limit and Upper Limit. 
  2. Then the computer Generates a random secret Number and stores it in its memory. 
  3. The computer then asks the user to guess the Number by a prompt. 
  4. If the user Number is less then the secret Number it Returns a Message. 
  5. If The Number is Equal To the Number it gives the 2nd Message. 
  6. If Number is Greater then the Secret Number it shows the Third Message.

The Process Involved in the Game:-

The game includes following header files atleast
#include<iostream.h>
#include<stdio.h>
using namespace std;

The process of the game usually starts with the main function.
main( )
{
}
Now as we analyze earlier we have 4 integer values in the game
int SecertNumber
int UserNumber
int LowerLimit
int UpperLimit

  1. The secret number is the number generated by computer.
  2. The user Number is the number asked by the computer as a guess. So user will input that number.
  3. The LowerLimit and UpperLimit are also prompted from user.
  4. Note that all number should be equalize to 0 while defining.
Now when we have defined the integers we can move on with building our program.

ask the user to enter upper and lower limits at this stage

cout << "Please Enter the Lower Limit="
cin >> LowerLimit

cout << "Please Enter the Upper Limit="
cin >> UpperLimit

Now it is the Time to Generate a Random Secret Number

srand(time(NULL))
SecretNumber = rand()%upperlimit+lowerlimit
cout<<"Done!"<<endl<<endl

Well NOW ONLY THING YOU NEED IS TO GENERATE THE TEST FOR YOUR RANDOM GENERATED NUMBER

ask the user to Guess the secret number

cout << "Please guess the secret Number"
cin >> UserNumber

NOW USE IF , ELSE IF and ELSE To show weather the Number is > then SecretNumber, OR IT IS > then SecretNumber or == to the SecretNumber

HURRAH HERE GOES THE CODE FOR THE GAME.

.
.
.

THANKS TO OUR TEAM IN THE BASEMENT