Você está na página 1de 7

Computer Programming – Question Bank (Two Marks)

1. Define computer.
A computer is an electronic device that manipulates information, or data. It has the ability to store,
retrieve, and process data.
2. What are the characteristics of computer?
No thoughts
3. List some important hardware and software technologies of fifth generation computers.
Artificial intelligence
Natural language processing
Parallel Processing
Superconductor technology
4. What is super computer? Give an example.
A supercomputer is a computer with great speed and memory.
Supercomputers are very expensive and are employed for specialized applications that require
immense amounts of mathematical calculations.
This kind of computer can do jobs faster than any other computer of its generation.
They are usually thousands of times faster than ordinary personal computers made at that time.
5. What are the applications of computers?
(i) Business (ii) Banking (iii) Insurance
(iv) Education (v) Marketing (vi) Health Care
(vii) Engineering Design (viii) Military (ix) Communication
(x) Government
6. What are the input and output devices?
Input devices
This unit contains devices with the help of which we enter data into computer. This unit makes link
between user and computer.
 Keyboard Mouse Joy Stick
 Light pen Track Ball Scanner
 Graphic Tablet Microphone
Output devices
Output unit consists of devices with the help of which we get the information from computer. This
unit is a link between computer and users. Output devices translate the computer's output into the
form understandable by users. Following are few of the important output devices which are used in a
 Monitors
 Graphic Plotter
 Printer
7. What is CPU?
CPU is considered as the brain of the computer. CPU performs all types of data processing operations.
It stores data, intermediate results and instructions (program). It controls the operation of all parts
of computer. CPU itself has following three components
 ALU(Arithmetic Logic Unit)
 Memory Unit
 Control Unit
8. Define flow chart. Why is flow chart required?
A flowchart is a type of diagram that represents an algorithm, workflow or process, showing the
steps as boxes of various kinds, and their order by connecting them with arrows. This diagrammatic
representation illustrates a solution model to a given problem.
9. Define pseudo code.
Pseudo code is an informal high-level description of the operating principle of a computer program
or other algorithm. It uses the structural conventions of a programming language, but is intended for
human reading rather than machine reading.
10. What is an algorithm?
An algorithm is a step-by-step procedure to solve a given problem. An algorithm is a representation
of a solution to a problem.

1. What are the features of C?
 Well suited for structured modular programming.
 Robust language with rich set of built-in functions and operators.
 Has minimal instruction set and programs written in are efficient and fast.
 Highly portable.
 Highly flexible.
 Allows access to the machine at bit level (Low level (Bitwise) programming).
2. Draw the structure of C program.
A C program basically has the following form:

Documentation Section 3.
Link Section
Definition Section
Global Declaration Section
Declaration Section
Executable part
Subprogram section
Function 1
Function 2
function n

3. What are C character set?

o Letters (A….Z, a….z )
o Digits 0…9
o Special characters
o Escape Sequences
4. Define token.
A token is a sequence of characters that is understood as a unit. Tokens are the basic building blocks
of a C program. C tokens fall roughly into the six categories listed below.
Keywords Identifiers Constants
Strings Special Symbols Operators

5. List different data types in C.

S.No Data Types Example

1 Basic data types int, char, float, double
2 Enumeration data type enum
3 Derived data type pointer, array, structure, union
4 void data type void

6. What are C constants?

C Constants refers to the data items that do not change their value during the program execution.
Several types of C constants are available in C. They are:
o Numeric Constants
 Integer Constants
 Real Constants
o Character Constants
 Single Character Constant
 String Constant
7. Define delimiters.
A delimiter is a unique character or series of characters that indicates the beginning or end of a
specific statement, string or function body set. Examples are:
 Round brackets or parentheses: ( )
 Curly brackets: { }
 Escape sequence or comments: /*
 Double quotes for defining string literals: " "
8. What is the important of keywords in C?
C keywords are the words that convey a special meaning to the c compiler. The keywords cannot be
used as variable names because by doing so, we are trying to assign a new meaning to the keyword
which is not allowed. Some of them are:

auto break case char const

continue default do double else
enum extern float for goto

9. What are various types of C operators?

Arithmetic Operators Relational Operators Logical Operators
Assignment Operators Increment and Decrement Operators
Conditional Operators Bitwise Operators Special Operators
10. What is enumerated data type?
Enumeration data type is a user defined data type that assigns values during compilation time. It
consists of integer constants that should be named as a list. It always starts with 0(zero) by default
and values are incremented by 1 for the next identifiers in the list. It can be specified using the
keyword ‘enum’.
enum identifier { enumerator-list }
11. Give an example for ternary operator.
Conditional operators or the ternary operators are used for decision making in C. The operator are
question mark (?) and the colon (: ).
The general syntax is:
Variable = condition? exp1: exp2
12. What is a variable? Illustrate with an example.
Each program elements in a C program are given a name called variables or identifiers. Names
given to identify Variables, functions and arrays are examples for identifiers.
Eg. X, total, avg_marks, sum1
13. What are the rules to be defined for variables?
o They must begin with a letter or underscore (_).
o They must consist of only letters, digits, or underscore. No other special character is allowed.
o It should not be a keyword.
o It must not contain white space.
o It should be up to 31 characters long as only first 31 characters are significant.
14. What is the difference between while loop and do while loop?

while loop do-while loop

The while loop tests the condition before The do – while loop tests the condition
each iteration. after the first iteration.
If the condition fails initially the loop is Even if the condition fails initially the
Skipped entirely even in the first loop is executed once.

15. What is the difference between break and continue?

break continue
Used to terminate the loops or to exit Used to transfer the control to the start
loop from a switch. of loop.
The break statement when executed Continue statement when executed
causes immediate termination of loop causes Immediate termination of the
containing it. current iteration of the loop.

1. Define array. What are its types?
C programming language provides a data structure called the array, which can store a fixed-size
sequential collection of elements of the same type. An array is used to store a collection of data, but it
is often more useful to think of an array as a collection of variables of the same type.
Types are:
o One-dimensional arrays
o Multidimensional arrays
2. What are the advantages of array?
 It is used to represent multiple data items of same type by using only single name.
 It can be used to implement other data structures like linked lists, stacks, queues, trees,
graphs etc.
 2D arrays are used to represent matrices.
3. How to declare and initialize one dimensional and two dimensional array? Give an example.
(i) One-dimensional array:
data_type array_name[array_size];
int age[5];

int age[5]={2,4,34,3,4};
(ii) Multidimensional Array:
data_type array_name[array_size][array_size];
int c[5][4];
int c[2][3]={{1,3,0}, {-1,5,9}};
4. Define string. List any four string handling functions.
Strings are sequence of characters enclosed within double quotes. Every string constant is
automatically terminated with a special character ‘\0′ called the null character which represents the
end of the string.
“hello”, “abc”, “hello911″
String Functions:
Function Work of Function
strlen() Calculates the length of string
strcpy() Copies a string to another string
strcat() Concatenates(joins) two strings
strcmp() Compares two string
strlwr() Converts string to lowercase
strupr() Converts string to uppercase
strrev() Reverse the string

5. How is a character string declared & initialized? Give an example.

char array_name[array_size];
char str[5];
In C, string can be initialized in different number of ways.
char c[]="abcd"; OR,
char c[5]="abcd"; OR,
char c[]={'a','b','c','d','\0'}; OR;

1. Define function. What is the need for function?
Functions are smaller self-contained components which carry out some specific, well defined task.
The benefits are:
 It facilitates top-down modular programming
 It avoids the need for redundant code
 It facilitates reusability
 It can be used to build a customized library of frequently used routines
2. What is function prototype?
Declaration of a function is called function Prototype. Prototype specifies the signature of the
function, the return type and number and data types of the arguments. Functions must be declared

before it is called. In C, prototyping is not mandatory; it is needed if a function call precedes function
return_type function_name (function arguments);
3. Define Recursion.
A function which call by itself is called recursion. A recursive function must have the following
 The problem must be written in a recursive form.
 There must be a base criteria (terminating condition) for which the function doesn’t call itself.
4. What is the difference between call by value and call by reference?

Call by Value Call by Reference

This method copies the actual value of an This method copies the address of an
argument into the formal parameter of the argument into the formal parameter.
Changes made to the parameter inside the Changes made to the parameter affect the
function have no effect on the argument. argument.
Pointers are not used Pointers are used

5. Compare actual parameter and formal parameter.

Actual parameter Formal parameter

Parameters which are in calling subprogram Parameters which are in called subprogram
are actual parameters. are formal parameters.
Actual parameters can be constants ,variables Formal parameters are only variables.
or expression
Actual parameters sends value to the formal Formal parameters receive values from actual
parameters parameters.

6. What is the use of pointers?

A pointer is a variable whose value is the address of another variable, i.e., direct address of the
memory location. The general form of a pointer variable declaration is:
type *var-name;
int *ip; /* pointer to an integer */
double *dp; /* pointer to a double */
7. What is address and indirection operator?
Address operator: &
Indirection or dereferencing operator: *

1. Define structure.
 The structure is a derived data type used to represent heterogeneous data.
 A structure is an aggregation of components that can be treated as a single variable. The
components are called members.
struct employee
int code;
char name[20];
int dept_code;
float salary;
struct employee emp1;
2. What is the purpose of union in C?
A union is a special data type available in C that enables you to store different data types in the same
memory location.
union employee
int code;
char name[20];
int dept_code;
float salary;
union employee emp1;
3. Differentiate structures and unions.

Structure Union
It allocates memory equal to sum of memory It allocates piece of memory that is Large
allocated to its each individual member. enough to hold the Largest variable of type in
struct keyword is used union keyword is used
each member have their own memory space. one block is used by all the members of union.
structure can not be implemented in shred Union is the Best environment where memory is
memory. shared.
it has less Ambiguity. Ambiguity is more in union.
All members can be accessed at a time. only one member is accessed at a time.

4. What is the use of preprocessor directives? Give an example.

The preprocessor provides the ability for the inclusion of header files, macro expansions, conditional
compilation, and line control. Preprocessing Directives are mainly classifieds into:
 File Inclusion
 Macro Substitution
 Conditional Compilation
5. What are the storage classes available in C?
A storage class defines the scope (visibility) and life time of variables and/or functions within a C
Program. They are:
 auto
 register
 static
 extern
6. Define static variable.
Static variables are also local (visible) to the block in which the variable is declared. They retain the
values throughout the life of the program. If not initialized in the declaration, it is automatically
initialized to zero. Static variable values are stored in Memory.
static data_type variable_name;