# B.Tech. (SEM-II) THEORY EXAMINATION 2016-17 COMPUTER SYSTEM & PROGRAMMING IN C

Time: 3hrs
Total Marks: 100

Note:-

• There are three sections. Section A carries 20 marks, Section B carries 30 marks and Section C carries 50 marks.
• Attempt all questions. Marks are indicated against each question.
• Assume suitable data wherever necessary.

Section – A

1. Explain the following: (2*10 = 20)

1. What is meant by modular programming approach?

Modular programming is the process of subdividing a computer program into separate sub-programs. A module is a separate software component. It can often be used in a variety of applications and functions with other components of the system.

• Some programs might have thousands or millions of lines and to manage such programs it becomes quite difficult as there might be too many of syntax errors or logical errors present in the program, so to manage such type of programs concept of modular programming approached.
• Each sub-module contains something necessary to execute only one aspect of the desired functionality.
• Modular programming emphasis on breaking of large programs into small problems to increase the maintainability, readability of the code and to make the program handy to make any changes in future or to correct the errors.
2. What is operator?

We can define operators as symbols that helps us to perform specific mathematical and logical computations on operands. In other words we can say that an operator operates the operands.
For example, consider the below statement:

```c = a + b;
```

Here, ‘+’ is the operator known as addition operator and ‘a’ and ‘b’ are operands. The addition operator tells the compiler to add both of the operands ‘a’ and ‘b’.

3. What is structured programming approach?

Structured Programming Approach, as the word suggests, can be defined as a programming approach in which the program is made as a single structure. It means that the code will execute the instruction by instruction one after the other. It doesn’t support the possibility of jumping from one instruction to some other with help of any statement like GOTO, etc. Therefore, the instructions in this approach will be executed in a serial and structured manner. The languages that support Structured programming approach are:

• C
• C++
• Java
• C#
• ..etc

4. What is type conversion?

When you assign the value of one data type to another, the two types might not be compatible with each other. If the data types are compatible, then the compiler will perform the conversion known as Type Conversion.

There are two types of Type Conversion:

1. Implicit Type Conversion
2. Explicit Type Converstion
5. Write a function to interchange the two values of two variables without using third variable.

 `void` `swap(``int``* xp, ``int``* yp) ` `{ ` ` `  `    ``// Code to swap 'xp' and 'xy' ` `    ``*xp = *xp ^ *yp; ` `    ``*yp = *xp ^ *yp; ` `    ``*xp = *xp ^ *yp; ` `} `

6. Define function declaration.

Function declaration tells compiler about number of parameters function takes, data-types of parameters and return type of function. Putting parameter names in function declaration is optional in function declaration, but it is necessary to put them in definition.
7. Enlist different file opening modes in C.

File opening modes in C:

• “r” – Searches file. If the file is opened successfully fopen( ) loads it into memory and sets up a pointer which points to the first character in it. If the file cannot be opened fopen( ) returns NULL.
• “w” – Searches file. If the file exists, its contents are overwritten. If the file doesn’t exist, a new file is created. Returns NULL, if unable to open file.
• “a” – Searches file. If the file is opened successfully fopen( ) loads it into memory and sets up a pointer that points to the last character in it. If the file doesn’t exist, a new file is created. Returns NULL, if unable to open file.
• “r+” – Searches file. If is opened successfully fopen( ) loads it into memory and sets up a pointer which points to the first character in it. Returns NULL, if unable to open the file.
• “w+” – Searches file. If the file exists, its contents are overwritten. If the file doesn’t exist a new file is created. Returns NULL, if unable to open file.
• “a+” – Searches file. If the file is opened successfully fopen( ) loads it into memory and sets up a pointer which points to the last character in it. If the file doesn’t exist, a new file is created. Returns NULL, if unable to open file.
8. What is meant by linkedlist?

A linked list is a linear data structure, in which the elements are not stored at contiguous memory locations. The elements in a linked list are linked using pointers as shown in the below image:

In simple words, a linked list consists of nodes where each node contains a data field and a reference(link) to the next node in the list.

9. Write the use of ‘switch’ statement?

Switch case statements are a substitute for long if statements that compare a variable to several integral values:

• The switch statement is a multiway branch statement. It provides an easy way to dispatch execution to different parts of code based on the value of the expression.
• Switch is a control statement that allows a value to change control of execution.
10. Explain various data types?

Following are the examples of some very common data types used in C:

• char: The most basic data type in C. It stores a single character and requires a single byte of memory in almost all compilers.
• int: As the name suggests, an int variable is used to store an integer.
• float: It is used to store decimal numbers (numbers with floating point value) with single precision.
• double: It is used to store decimal numbers (numbers with floating point value) with double precision.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.