# 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. Attempt all questions: (2*10 = 20)

1. Explain the basic structure of a C program.

The structure of a C program is as follows:

2. Main Method Declaration
3. Variable Declaration
4. Body
5. Return Statement
2. What do you mean by algorithm? Explain the characteristics of algorithm.

The word Algorithm means “a process or set of rules to be followed in calculations or other problem-solving operations”. Therefore Algorithm refers to a set of rules/instructions that step-by-step define how a work is to be executed upon inorder to get the expected results.

Characteristics of an Algorithm

• Clear and Unambiguous: Algorithm should be clear and unambiguous. Each of its steps should be clear in all aspects and must lead to only one meaning.
• Well-Defined Inputs: If an algorithm says to take inputs, it should be well-defined inputs.
• Well-Defined Outputs: The algorithm must clearly define what output will be yielded and it should be well-defined as well.
• Finiteness: The algorithm must be finite, i.e. it should not end up in an infinite loops or similar.
• Feasible: The algorithm must be simple, generic and practical, such that it can be executed upon will the available resources. It must not contain some future technology, or anything.
• Language Independent: The Algorithm designed must be language-independent, i.e. it must be just plain instructions that can be implemented in any language, and yet the output will be same, as expected.
3. What are functions? What is the advantage of using multiple functions in a program?

A function is a set of statements that take inputs, do some specific computation and produces output.

The idea is to put some commonly or repeatedly done task together and make a function, so that instead of writing the same code again and again for different inputs, we can call the function.

Advantage of using multiple functions in a program

1. Ease of Use :This approach allows simplicity, as rather than focusing on the entire thousands and millions of lines code in one go we can access it in the form of modules. This allows ease in debugging the code and prone to less error.
2. Reusability :It allows the user to reuse the functionality with a different interface without typing the whole program again.
3. Ease of Maintenance : It helps in less collision at the time of working on modules, helping a team to work with proper collaboration while working on a large application.
4. Distinguish between int main() and void main()?

int main(): This prototype refers to the main function in a C program that returns an integer value. This integer value is the exit code of the program that defines if the program has completed successfully or not. For successful execution, 0 is returned. Else any other value is returned. This format is now the standard ANSI defined format for the main() method in C programming.

void main(): This prototype refers to the main function in a C program that do not returns any value. Earlier this prototype were used but now this format is not recommended by the standards and must not be used.

5. What is the difference between pseudo-code and flowchart?

Pseudo-code is a step-by-step representation of how to solve a problem in the form of text in any language.
For example:

```check whether the number is even or odd.

if "1"
print response
"I am case 1"

if "2"
print response
"I am case 2
```

Flowchart is a step-by-step representation of how to solve a problem in the form of graphical representation
For example: Flowchart to input two numbers from user and display the largest of two numbers

6. Draw the memory hierarchical structure of a computer system.

7. What will be the output of following code?

 `void` `main() ` `{ ` `    ``int` `a = 5, b = 6; ` `    ``printf``(``"%d\t"``, a = b); ` `    ``printf``(``"%d\t"``, a == b); ` `    ``printf``(``"%d\t%d"``, a, b); ` `} `

Output:

```6    1    6    6
```
8. Write short notes on High level and low level languages.

High level languages are nearly human languages. In other words, these are the languages in which the code are written in a language which are more understood by the human than by the machines.

Low level languages are nearly machine languages. In other words, these are the languages in which the code are written in a language which are more understood by the machines than by the humans.

9. Write short note on Union and enumerated data type.

Enumerated Data-type: Enumeration (or enum) is a user defined data type in C. It is mainly used to assign names to integral constants, the names make a program easy to read and maintain.

`enum State {Working = 1, Failed = 0}; `

The keyword ‘enum’ is used to declare new enumeration types in C and C++.

Union: Like Structures, union is a user defined data type. In union, all members share the same memory location.

10. Write five commands of LINUX with its architecture?

1. who
`\$who [options] [filename]`
2. ping
`sudo ping -v`
3. tar
`tar [options] [archive-file] [file or directory to be archived]`
4. netstat
`# netstat -a | more `
5. expand
`\$expand [OPTION] FILE`

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.