Very Short Questions Fall 2017
The answers to Very Short Questions Spring 2017 are given below:
1. Define the term FILE in file handling?
ANS- Generally, the file is used to store the data. The term File Handling refers to the various operations like creating the file, reading from the file, writing to the file, appending the file, etc. There is two basic operations which is mostly used in file handling is reading and writing of the file.
2. Write the syntax of for, while and do-while loop.
ANS- For loop syntax:
for (initializationStatement; testExpression; updateStatement)
// statements inside the body of loop
While loop syntax:
// the body of the loop
Do-while loop syntax:
// the body of the loop
3. What does *p mean?
ANS- *p is the declarator. The declarator introduces the name of the object being declared (p), along with additional type information not provided by the type specifier. In this case, the additional type of information is that p is a pointer type.
4. Why function is used.
ANS- We use functions in programming to bundle a set of instructions that we want to use repeatedly or that, because of their complexity, are better self-contained in a sub-program and called when needed. That means that a function is a piece of code written to carry out a specified task.
5. Explain about preprocessor directive?
ANS- Preprocessor directives are lines included in a program that begin with the character #, which make them different from a typical source code text. They are invoked by the compiler to process some programs before compilation. Preprocessor directives change the text of the source code and the result is a new source code without these directives.
6. Mention some characteristics of a good algorithm.
ANS- The characteristics of a good algorithm are given below:
- Finiteness, means it must always terminate after a finite number of steps.
- Definiteness, means each step must be precisely defined and clear.
- Input, means it has zero or more inputs, i.e., an algorithm can run without taking any input.
- Output, means it has one or more outputs, i.e., an algorithm must produce atleast one output.
7. Define malloc and calloc function.
ANS- The name malloc and calloc () are library functions that allocate memory dynamically. It means that memory is allocated during runtime (execution of the program) from the heap segment. Malloc () function is used for allocating a block of memory at runtime and calloc () is another memory allocation function that is used for allocating memory at runtime.
8. Where & and -> operators are used.
ANS- & operator is used to Returns the address of a memory location. -> is used in structure and union member access through a pointer.
9. Define string.
ANS- A String in C is a collection of characters in a linear sequence. ‘C’ always treats a string a single data even though it contains whitespaces. A single character is defined using a single quote representation. A string is represented using double quote marks.
10. Define union.
ANS- A union is a special data type available in C that allows to storage of different data types in the same memory location. You can define a union with many members, but only one member can contain a value at any given time. Unions provide an efficient way of using the same memory location for multiple-purpose.
You may also like Pokhara University || Fall, 2017 || Programming Language