We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>

www.vustudents.ning.com

 www.bit.ly/vucodes + Link For Assignments, GDBs & Online Quizzes Solution www.bit.ly/papersvu + Link For Past Papers, Solved MCQs, Short Notes & More

Dear Students! Share your Assignments / GDBs / Quizzes files as you receive in your LMS, So it can be discussed/solved timely. Add Discussion

# CS201 Introduction to Programming Lecture no. 26 Discussions and Solution

Q.explain DT or DC in simple wording or its function.

ANS:

DTE: Any device that is a source of or destination of digital data

DCE: Any device that transmits/receives signal through network

If you are asking for DC component Then DC in data transmission; if average amplitude of signal is non-zero and frequency of signal become zero then there present the DC component.

 Q.Explain me the abrivation of TX. Explain the word of TX. ANS:   For any Information or data to be communicated over a network there is a node that generates or transmits that information. The sender node point which is transferring information is termed here as “TX" or Transmitter point & the Destination node point that has to receive that information is abbreviated as “RX" or receiver point. TX medium is the physical path through which data travels from one node to another (Twisted Pair cables etc.).

 Q.what is ITU-T stand for? ANS: ITU stands for International Telecommunication Union (ITU) and it coordinates the standards for telecommunications (T) .That why it is called ITU-T.

 Q.Is PCM is in the modem ?   ANS: PCM is used to convert analog signal to digital signal. As you know, modem is modulator and demodulator for the analog signal. So, modem uses PCM for analog to digital conversion.

 Q.In the 23rd lec about redundant bit in V.33 so what is redundant bit? Another question is what is ISP(Internet Service Provider) is it like PTCL in Pakistan Is PTCL Working as ISP? ANS: To overcome the errors in data transmission, some time an extra bit is appended in ever data unit before transferring it on the medium. This extra bit is called redundant bit. At page 170 in handouts, redundancy topic will clarify this concept. You should also read VRC and parity bit fro more details. An ISP links your computer to the internet. So, PTCL is an example of ISP.

 Q.Can digital data not transmit through Modem ? Because Modem converts the digital data into analog and if digital data can also transmit so which is faster for transmitting the data? ANS: Digital data is always in the binary form (0s and 1s). To transmit this data over the internet to other system, it has to be changed in electric pulses (wires), terrestrial wave form (wireless media) or light beam (fiber optics).

 Q.what type of signal conversion required when we r talking to overseas friend ? ANS:   When two people communicate via a telephone line then this type of communication requires Analog to Analog conversion because human voice comes in Analog category of signals and typical telephone lines carry Analog signals.So, Analog to Analog conversion is required.

+ How to Join Subject Study Groups & Get Helping Material?

+ How to become Top Reputation, Angels, Intellectual, Featured Members & Moderators?

+ VU Students Reserves The Right to Delete Your Profile, If?

Views: 264

.

+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

### Replies to This Discussion

 Q.AS MODEM is the example of DCE please give me such concrete some examples of interface. ANS:  Interface refers to a tool and a concept that provides a point of interaction between components. It can be in the form of hardware and software. Interface allows two independent systems to meet or communicate with each other.   So, in the context of your query, the wire connectors, plugs and sockets which are used to connect a modem with other system are the examples of interface.

 Q.What is ISP and what is ISP stands for? ANS:  ISP is short for Internet Service Provider. It refers to a company or a body that provides Internet services, including personal and business access to the Internet. For example, PTCL (Pakistan Telecommunication Company Limited) is serving as an ISP in Pakistan.

 Q.At type of signal conversion required when we r talking to overseas friend ? ANS:    When two people communicate via a telephone line then this type of communication requires Analog to Analog conversion because human voice comes in Analog category of signals and typical telephone lines carry Analog signals.So, Analog to Analog conversion is required.

 Q.Up to the switching station the transmission medium can handle only sin wave signals, which medium is used from switching station to the ISP that can carry digital signals? ANS: Circuit Switching is the term used in Telecommunication networking which means Prior to any transmission a predetermined path is established which is followed by the data. Circuit switching involves creating a direct physical connection between sender and receiver, a connection that lasts as long as the two parties need to communicate. In order for this to happen, of course, the connection must be set up before any communication can occur. Once the connection is made, however, the sender and receiver can count on "owning" the bandwidth allotted to them for as long as they remain connected.As for as the medium is concerned it depends on the designing of the network, It can be optical fiber, Copper pair or it can be microwave.

 Q.If you are using DSL modem at your home, which is utilizing same telephone line to transmit and receive data from ISP; but in this case my download speed is 2 Mbps; how DSL modem is able to manage speeds greater than 56 Kbps? kindly explain your answer in detail...thanks in advance...Regards ANS:  Our wired telephone system uses copper lines which are twisted together in a pair and connected to each subscriber’s telephone at one end and the switching mechanism at the other end at the telephone exchange. It uses an analog system to convert the voice signals into an electrical signal and transfer that back and forth. Traditional phones do not utilize the full amount of the signals that are available and as a result the maximum speeds that you can get using a dial-up connection are only 128 Kbps. A DSL modem takes the analog signals and converts them into digital signals or bits. Thus they can transfer higher bandwidth of data and using the modulation and demodulation processes.

Q.we have learned that since telephone lines have a limitation of bandwidth that is maximum band is 4000Hz so as per nyquist criteria samples should be double i.e. 8000 sample/sec when multiply by 7 bits/sample results in 56 Kbps, which is the maximum download speed on normal telephone line. sir kindly explain why the bandwidth of telephone line is limited to 4000 hz?

ANS:

The audible frequencies range between 20Hz to 20000 Hz, Most information in human speech is in frequencies below 10,000 Hz thus a 20,000 Hz sampling rate would be necessary for complete accuracy. But telephone speech is altered by the switching network, and only frequencies less than 4,000 Hz are transmitted by telephones. Thus an 8,000 Hz sampling rate is sufficient for telephone-bandwidth speech like the Switchboard corpus. A 16,000 Hz sampling rate (sometimes called wideband) is often used for microphone WIDEBAND speech. Even an 8,000 Hz sampling rate requires 8000 amplitude measurements for each second of speech, and so it is important to store the amplitude measurement efficiently. They are usually stored as integers, either 8-bit (values from -128–127) or 16 bit (values from -32768–32767). This process of representing real-valued numbers as integers is called quantization because there is a minimum granularity (the quantum size) and all values which are closer together than this quantum size are represented identically.

Q.why we need all that kind of connectors and port if we can work with the same old fashion port ??

ANS:

We can use ports and connectors for connectivity which is necessary for communication.

Q.In case of transmission between computer A and ISP, digital data from computer is sent to modem, which converts it to analog signal and send it to local telephone exchange, which converts this analog signal to digital using PCM and quantization. Now the bytes travelling on telephone network is the integer representation of amplitude levels of an analog signal; Does that means ISP send the INTERNET data to the computer in PCM format as well? whereas ISP are receiving data on TCP/IP protocol?? Kindly explain??

ANS:
Whenever analog data is sent it will be digitized and prior to digitizing a signal PCM technique is used where Signal is Sampled, Quantized and then ecoded to send on transmission medium.
When data travells over the internet it follows the TCP/IP model to travell across the entire network nodes, Different protocols of layers are followed at different levels according to the unctiones defined.

Q.In case of traditional modems digital data from computer is sent to modulator which converts it to analog then telephone network company further converts analog to digital using PCM technique. Why can't the data be transmitted directly from the computer on the telephone network in digital format, in this case we will not require modem and not need of PCM quantization, and transmission rates can also be enhanced?

ANS:

Because data travels in telephone network is in analog signal form.

Q. In case of V .33 modem it is 128 QAM that is 7 bits are transmitted for every change in phase or amplitude. what is the purpose of 1 redundant bit in this case? as only 6 bits are used to transmit data?

ANS:

In case of V .33 modem ( 128 QAM) 6-bitS represents data and one bit redundant IS USED to detect error.

Q. In which program we write our on header file with extension .h? 2.why we use #define and not simple variables? 3.what are macros and why we use macros in our programs?

ANS:

Being a programmer, if your program contains many user defined functions, you can create your own header file for that program. It is up to your choice when to make header files for your program. The important thing is that header files increase code reusability.

Macro is a special name, which is substituted in the code by its definition, and as a result, we get an expanded code. For example, we are writing a program, using the constant Pi. Pi is a universal constant and has a value of 3.1415926. We can declare a macro for holding the value of Pi. If you want to use a constant value in your program more than once, then it is better to declare a macro instead of declaring a constant variable because declaring a constant variable requires memory to be allocated which is an overhead.

Q. hy we make our own header file?

why we use macro?

why spaces are not allowed and which program it is allowed?

when semicolons are not used in programs?

ANS:

A header file contains declarations of functions and variables. Every external function will be mentioned in a header file, including libraries that are pre-compiled into object code, and source files required to build the C program. When the programmer has functions that provide additional capabilities, then he might want to create his own separate header file to contain these functions. One advantage of making user-defined header files is to reuse the same code again and again. So header files increase code reusability.

Macro is a special name, which is substituted in the code by its definition, and as a result, we get an expanded code. For example, we can declare a macro for defining the value of PI in our program.

Your third question is unclear. Kindly make it clear what do mean by spaces in program ?

The semicolon(;) is used to terminate the statement in a program. Every statement of our code is terminated by a semicolon. We do not use semicolon at the end of header file declaration becuase declaration of header file is not a C statement. There are many other places in the code where semicolon is not used. I advise you to understand the code syntax carefully only then you will be able to find your answer.

Q. Why are we not declairing the type of variable are some thing else in #define PI 3.143232 etc. The compiler knows that why is this.

ANS:

The macro #define PI 3.143232 is like declaring a constant value for PI but it is not actually a variable. Actually we are using this for defining a name PI to our value 3.143232. It means that whenever in our program we want to use the value 3.143232, we simply use the word PI and compiler automatically replaces the value instead of name PI. The advantage of doing such is that no variable is created in the memory and so it saves our memory.

Q. i).what is difference between header files and libraries? ii).Are header files only contain function prototypes or function definitions also?

ANS:

Header files typically only contain declarations. They do not define how something is implemented, and you already know that your program won’t link if it can’t find the implementation of something you use. These files allow programmers to separate certain elements of a program's source code into reusable files. Header files commonly contain forward declarations of classes, functions, variables, and other identifiers. A library is a package of code that is meant to be reused in many programs. Typically, a library includes a header file that contains declarations for everything the library wishes to expose (make public) to users, and a precompiled object that contains all of the implementation code compiled into machine language.

Q. what is stack?explain briefly.

ANS:

In computer science, a stack is a data structure in which which elements are stored in Linear order on the basis on Last in First out (LIFO). A stack can have any abstract data type as an element. There are three basic operations associated with stack. In programming, stack is used when we call some function so that it helps in saving the state of the program. A stack is used to hold information about function calling and nesting in order to switch to the context of the called function and restore to the caller function when the calling finishes. Also Stacks are an important way of supporting nested or recursive function calls. It also supports the creation, maintenance and destruction of each called function's automatic variables.

Q.Explain me about dynamic memory allocation.

ANS:

Dynamic memory allocation is the allocation of memory storage for use in a computer program during the run-time of that program.Dynamically allocated memory exists until it is released either explicitly by the programmer, or by the garbage collector. This is in contrast to static memory allocation. It is also known as heap-based memory allocation.

Q. what is key stroke?define me with examples

ANS:

A keystroke is typing one character (not stroking your keyboard like a cat). Every time you hit a key, you perform a keystroke. So 5400 keystrokes in one hour means hitting 5400 keys in one hour, or 90 keys a minute. Sometimes keystrokes per minute is used to measure typing speed instead of words per minute.

Q. we say these #inclue<iostream.h> preprocesser directives or header files or libtraries ?clear it

ANS:

# is called preprocessor directive and iostream.h / conio.h /stdio.h are called header files.  Each header file serves some special purpose. For example, stdio is used in that problem in which cin and cout are used. So use of header file is dependent on functionality required.

Q. if we write just the prototype(declaration) of the function in our header files, then where we define our functions? From where our program will get the definition of any function if just we included those header files in which we wrote just the prototype of the function?

ANS:

The declarations of the functions are provided in the user defined header files and their definitions are provided in separate file(.cpp) which contains the actual code of our program but first make sure to include those header files in the program.

Q. can we use const PI = 3.14 instead of #define PI 3.14? If we can then which would be more efficient?

ANS:

We can use it in both ways but const double PI= 3.1415926 is used when we want more accuracy. If you are concerned with efficiency then # define PI 3.14 is used because it is constant defined by language.

Q. if we declared 2 dimentional array and we want to call a function then what is the syntex to send the information.

for example if we have simple array then we sent array and it's size ..so in 2 d case what we will do. can you explain in detail with example.

ANS:

Function calling for a function taking 2D array as its parameter depends on the declaration of the that function and the way a 2D array is passed to that function. There can be more than one ways of passing a two dimensional array. I am providing some of the function declarations which takes a 2-D array as its parameter.

double f(double values[][4], int n);

In the above function declaration, the second parameter n tells the number of rows of this array as number of columns have already been declared in the second subscript of the the array. Thje function calling statement to call the above function is f(values, 10);  here 10 shows the number of rows of the two dimensional array. Similarly, we can declare a function with 2D array parameter as the one given below.

func(int a[5][7]) ;

In the above, the function can be called by simply giving the array name as the parameter to the function called. For example f(a).

Q. Can you give the example of 3  and   4 dimentional arrays.  and it is compulsary that for 2 dimestinoal we have to use nested loops. can we use 2 dimentional arrays without using even 1 loop? if yes then please give example.

ANS:

main()

int a[3][2][2];
int i j k;
for(i=0;i<3 i++)
for(j=0;j<2;j++)
for(k=0;k<2;k++)
{
cout i= dnj= dnk= dnnn i j k;
cout<" enter the value to store at the specified postionn ";
cin>> d a[i][j][k];

getch();

Now turn to your second part of the Question.
Accessing all of the elements of a two-dimensional array requires two loops: one for the row, and one for the column. Since two-dimensional arrays are typically accessed row by row, generally the row index is used as the outer loop.

Q. Is it compulsary that we will inisialize outside the main body? if yes the what is the main difference between global variable and it.

I need example that where we can use 3 dimentional rows. and about arrays, if i am making one char array like "char a[10]" so it must accept 9 character but when i am entering the data it is accepting more than 9 like much more as i can enter and even this data is printing. where this data is storing in the memory while we have limitation to enter just 9 characters.

ANS:

The const keyword is used to create a read only variable. Once initialised, the value of the variable cannot be changed but can be used just like any other variable. It is not compulsary to intialize them outside the main body.
Example:

main()
{
const int age = 28;

So here you have delcared in the main () function. One can also declare const out side the main () body.

Q.I did not get the concept of 3d arrays. because if we need 3 colulms or 4  or 5, we can do these things using 2d arrays. can you explain conceptually that where we can use 3d arrays mean which situation? you coded for me 1 example but i did not get. can you explain the purpose and example in real life....

ANS:

One use of three dimensional array is that when we want to save the record of some person in form of rows and columns and value for each element of the array is a character string. For example, if we want to store the record of VU students that is the student name and student VU ID and we know that both are in form of character strings so doing so can be achieved using a 3D array as in the code given below.

#include <iostream.h>

main()
{
char Student[2][2][10];

for(int i=0; i<2; i++)
{
for(int j=0; j<2; j++)
{
for(int k=0; k<10; k++)
{
cin>>Student[i][j][k];
}

}
}

system("pause");
}

In the above declared 3D character array, the first index shows number of students whose records will be saved. In this case the first index value is 2 so therefore we are storing the records of 2 students. The second index value is 2 which indicates that for each student, two type of information will be stored that is his/her name and id. The third index value is used for the number of characters for each character string to be stored.

Q.let spouse we declared one global variable "int a=10;" and later in the main statement we say "a=20;" so now it's value is 10 or 20? please explain in detail and give some examples......

ANS:

In such case, the value of the variable will be modified from 10 to 20. Below is the code which explains all this.
#include <iostream.h>
int a = 10;

main()
{
cout"Value of a = "a;
coutendlendl;

a = 20;

cout"New value of a = "a;

system("pause");
}

Compile and run this code and see the program output.

Q. main()

char a[10];

cout"Enter name:\t";
cin.getline(a, 10);
couta;
system("pause");

Q.you code for me this example but i did not get it. first of all you used fuction "getline(a,10);" but where is declaration where is defination? secondly what is this "cin.getline(a,10);"? after cin statement you did not use >> and put . and fucntion name............can you explain in detail?

ANS:

getline() is a system defined member function associated with cin. We do not need to declare or define this function as it is already been defined and we just need to call it. The getline function is the preferred method for reading lines of text from a stream, including standard input. In our above program code, we used a getline function with two arguments. The first argument is a character array 'a' which we declared earlier. The array should be large enough to hold the complete line. The second argument is the maximum number of characters to be read here the number of characters were 10. So the purpose of calling getline() function in our program was that we wanted to take a string of 10 characters from the keyboard and wanted to save it in the character array a.

Q.
in lecture number 14 you discussed the read problem. i have one problem in that programe. you made one array "luckyemp[arraysize]" and in starting you gave 0 to all locatoins.

now problem is , you used some function there and you passed this luckyemp array to the function but you did not use there. why? if there is no more use then why we send it there?

Please explain this point in detail.

ANS:

In the program for salary calculation provided in Lecture No.14, the array lucky[] is used to tell about the number of unlucky employees. Now here, the term unlucky is being used for that employee whose gross salary is greater than some other employee but after employee but after tax deduction, his net salary becomes less than the same employee. The array lucky[] is being passed as a parameter to some of the functions defined in the program where the unlucky employees are found out and they are stored in lucky[] array so therefore we do not need to use it in the main() function instead we pass it to some other function.

Q. jub men main() k sath void likhti hun tou compiler error deta hy k main must retrun int but books men main() k sath void likha hota hy mery code men kun nai chlta.

ANS:

Void means nothing.It is used when main function returns nothing. Your program would be returning some int value thats why error is appearing with void main. You should use int main(). Try this, i hope your problem would be solved.

Q. 1) What is directory?

2) Suppose we want to print a string by #define Then how it possible?

ANS:

1)   A directory or in other words a folder is a file system structure in which to store computer files.

2)   Below is the code in which we are printing some character string which was declared using #define directive.

#include <iostream.h>
#define name "Hello World";

main()
{

coutname;

system("pause");
}

A directory or in other words a folder is a file system structure in which to store computer files.

Q. What is a Good Program?

ANS:

Good program is a generic term and can be defined in many ways but generally we can say that a  good program is "a program that performs all required functionalities for which it is made along with efficieny and better memory utilization."

sir very very very very niceeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

## Latest Activity

Rana Ali liked Rana Ali's discussion waqat
14 seconds ago
Rana Ali posted discussions
39 seconds ago
Rana Ali liked Rehman's discussion A.R
19 minutes ago
Rana Ali replied to Rana Ali's discussion EDU302 Assignment NO 2 (Fall 2019) in the group EDU302 Human Development and Learning
21 minutes ago
26 minutes ago
DUA FATIMA joined + M.Tariq Malik's group

### ISL201 Islamic Studies

1 hour ago
Rehman updated their profile
1 hour ago
2 hours ago
Marium Batool updated their profile
2 hours ago
Hafiza Iqra Khan liked ٢١ دن's discussion گناہ
3 hours ago
3 hours ago

1

2