0% found this document useful (0 votes)
16 views9 pages

Viva Questions

It's useful

Uploaded by

sadharoopa287
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views9 pages

Viva Questions

It's useful

Uploaded by

sadharoopa287
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

1)Define Computer

The computer is an electronic device which converts raw data into valid or
meaningful
information.
2)Define Program
An intelligent machine that solves problems by accepting data, performing certain
operation
and producing the result under the direction of step by step instruction called program.
3)List out the types of Software?
a) System Software
b) Application Software
4)Define Compiler?
The program written in any high level language is converted into machine language
using a compiler. Compiler translate source code (user written program) into object code
(binary form)

5)Define Interpreter?
Interpreter analyses and executes the source code in line-by-line manner , without
looking at the entire program. The advantage of interpreter is that they can execute a
program spontaneously. Compiler requires some time before an executable program is
formed because it looks at the whole source code.

6)Define Assembler?
Assembly language is closest to the machine code. Assembly language is
fundamentally a symbolic representation of machine code. The assembly language program
must be translated into machine code by a separate program called an assembler.
7)List out the application software?
1) Word processors
2) Spreadsheets
3) Image editors
4) Database management systems
5) Presentation Applications
6) Desktop Publishing Software
8)What are the types of programming language?
• Machine language
• Assembly language
• High level language

9)What are the types of control statements and explain it.


I. Decision making statements
II. Loop control statements
III. Unconditional control statement

I. Decision making statements


1) Simple if Statement
2) if – else Statement
3) Nested if-else statement
4) else – if Ladder
5) switch statement
II. Loop control statements
1) for Loop
2) while Loop
3) do-while Loop
III. Unconditional control statements
1) goto Statement
2) break Statement
3) continue Statement

I Decision Making Statements

(i) Simple “if” statement:


Syntax:
if (Condition or test expression)

if (Condition or test expression) {


Statement; OR Statement;
Rest of the program; }
Rest of the program;

It is basically a “Two-way” decision statement (one for TRUE and other for FALSE) . It
has only one option. The statement as executed only when the condition is true. In case the
condition is false the compiler skips the lines within the “if Block”. The condition is always
enclosed within a pair of parenthesis ie ( ) .
(ii) “if-else” Statement:
It is observed that the if statement executes only when the condition following if is true.
In if-else either True-Block or False – Block will be executed and not both.
The “else” Statement cannot be used without “if”.

Syntax: if ( Test Expression or Condition )


{
Statements; /*true block (or) if block */
}
Else
{
Statements; /* false block (or) else block */
}
(iii) Nested “if–else” Statement:
Using of one if-else statement in another if-else statement is called as nested if-else control
statement.
When a series of decisions are involved, we may have to use more than one if-else statement
in nested form.
Syntax:
if ( Test Condition1)
{
if ( Test Condition2)
{
Statement -1;
}
else
{
Statement -2;
}
}
else
{
Statement -3;
}

(iv)The switch statement:


The switch statement is a multi-way branch statement.
In a program if there is a possibility to make a choice from a number of options, this
structured selected is useful.
The switch statement requires only one argument of int or char data type, which is checked
with number of case options.

If no one case constant not matched then default is executed.


Syntax:
switch(variable or expression)
{
case Constantvalue-1:
Block -1
break;
case Constantvalue-2:
Block -2;
break;
________
case Constantvalue-n:
Block -n;
break;
default: d
efault – block;
}
II Loop Control Statements:
Loop: A loop is defined as a block of statements which are repeatedly executed for certain
number of times.
i)The “for” loop:
“initialize expression”, “Test Condition expression” and “updation expression”

Syntax:
for(initialize expression; test condition; updation )
{
Statement-1;
Statement-2;
}
ii)Nested “for” loop:
Syntax:
for( initialize ; test condition ; updation)
{
for(initialize ; test condition ; updation)
{ Body of loop;
}
}
(ii) The “ while ” loop:
Syntax:
while( Test Condition)
{
Body of the loop;
}

The while is an entry – controlled loop statement.


The test condition is evaluated and if the condition is true, then the body of the loop is
executed.
The execution process is repeated until the test condition becomes false and the control is
transferred out of the loop.

(iii) The “ do-while “ loop:


In do-while, the condition is checked at the end of the loop.
The do-while loop will execute at least one time even if the condition is false initially.
The do-while loop executes until the condition becomes false.
Syntax:
do
{
Body of the loop;
}
while ( Test Condition);

10)What is Function and its types?


Functions are subprograms which are used to compute a value or perform a task.
They cannot be run independently and are always called by the main ( ) function or by some
other function.
There are two kinds of functions
1. Library or built–in functions
2. User–designed functions
Function declaration:
Syntax
type name (type arg1, type arg2 …….. type argn)
{
<local declaration >
< statement block>
--------------------
return (variable or expression
11)What are the uses of function ?
1. Functions are very much useful when a block of statements has to be written/executed
again and again.
2. Functions are useful when the program size is too large or complex.Functions are called
to perform each task sequentially from the main program. It is like a top-down modular
programming technique to solve a problem
3. Functions are also used to reduce the difficulties during debugging a program
}

12) What are the rules to call a function?


1. A function has a statement block which is called by the main( ) or any other function.
2. When the data type in a function declaration is omitted the function will return a value of
the type integer.
3. The data type of the formal argument may be declared in the next line which follows the
function declaration statement.

13)What is Function return type?


Functions in C may or may not return values. If a function does not return a value the
return type in the function definition and declaration is specified as void. Otherwise, the
return type is specified as a valid data type.
14)What is function parameter?
Function parameters are the means of communication between the calling and the the
called function. They can be classified into formal parameters and actual parameters. The
formal parameters are the parameters given in the function declaration and function
definition. The actual parameters, often known as arguments, are specified in the function
call.
15)What is function Call ?
A function call is specified by the function name followed by the values of the
parameters enclosed with in parenthesis, terminated by a semi colon (;).
There are two ways in which we can pass arguments to the function:
Call by value
Call by reference.
16)Define Call by value?
In this type value of actual arguments are passed to the formal arguments and the
operation is done on the formal arguments. Any changes made in the formal arguments does
not effect the actual arguments because formal arguments are photocopy of actual
arguments. Hence when the function is called by the call by value method, it does not effect
the actual contents of the actual arguments. Changes made in the formal arguments are local
to the block of called function.
17)Define call by reference?
In this type instead of passing values, addresses are passed. Function operates on
addresses rather than values. Here the formal arguments are pointers to the actual
arguments. In this type , formal arguments point to the actual argument. Hence changes
made in the arguments are permanent.
18) What are the Category of functions?
1.Function with no arguments and no return values:
2.Function with arguments but no return values:
3. Function with arguments with Return values
19)What is recursion ?
A function calling itself again and again to compute a value is known as recursive
function or recursion function or recursion. Normally a function is called by the main
program or by some other function but in recursion the same function is called by itself
repeatedly.
Use of recursion function :
1. Recursion functions are written less number of statements.
2. Recursion is effective where terms are generated successively to compute value.
3. Recursion is useful for branching process. Recursion helps to create short code that would
otherwise be impossible .
20) Define Array and its types?
An array is a fixed size sequenced collection of elements of the same data type.
It is simply grouping of like type data such as list of numbers, list of names
It allocates sequential memory locations.
Individual values are called as elements.
Types of Arrays:
One – dimensional arrays
Two – dimensional arrays
Multidimensional arrays
The general form of array declaration is
Syntax for 1 Dimensional array:
datatype array_name[sizeofarray];
Syntax for 2 Dimensional array:
data type array name[row size] [column size] ;
Syntax for Multi Dimensional array: :
datatype array_name [sizeofno.oftwoDimArray] [sizeofrow] [sizeofcolom];

The datatype specifies the type of element that will be contained in the array, such as int,
float, or char.
The size indicates the maximum number of elements that can be stored inside the array.
The size of array should be a constant value.
21)List out the String function and it uses?
 strlen( ) Function: strlen( ) function is used to find the length of a character
string.
 strcpy( ) Function: strcpy( ) function is used to copy from one string to another
string.
 strcat( ) Function: strcat( ) function is used to join character, Strings. When
two character strings are joined, it is referred as concatenation of strings.
 strcmp( ) Function: strcm ( ) function is used to compare two character strings.
 strupr( ): to convert all alphabets in a string to upper case letters.

 strlwr( ): To convert all alphabets in a string to lower case letters.

 (strrev( ): To reverse a string

 strncmp( ): To compare first n characters of two strings.

 strcmpi( ): To compare two strings with case in sensitive (neglecting upper /


lower case)

 strncat( ): To join specific number of letters to another string.

 isupper( ) : To test if a character is a upper case letters.

 islower( ) : To test if a charcter is a lower case letter.

 isalpha( ) : To test if a character is an alphabet.

 isalnum( ) : To test if a character is an alphabet or number.

 isdigit( ) : To test if a character is a number.

 isxdigit( ) : To test if a character is a Hexa decimal number (0-9, A-F and a-f are
Hexa decimal digits)

 tolower( ) : To convert an alphabet to lower case letter

 toupper( ) : To convert an alphabet to upper case letter

24)What is pointer?
A pointer is a variable which holds the address of another variable or identifier this
allows indirect access of data.
Syntax:
Data type *pointer variable;
The declaration tells the compiler 3 things about variable p
a) The asterisk (*) tells that variable p is a pointer variable
b) P needs a memory location
c) P points to a variable of type data type.
Pointer and functions
1. Pointers can be passed as argument to a function definition.
2. Passing pointers to a function is called call by value.
3. In call by reference what ever changes are made to formal arguments of the function
definition will affect the actual arguments in calling function.
4. In call by reference the actual arguments must be pointers or references or addresses.

25)Define Structure?
Structure is a collection of heterogeneous type of data i.e. different types of data. The
various individual components, in a structure can be accessed is processed separately. A
structure is a collection of variables referenced under a name, providing a convenient means
of keeping related information.
Declaration of structure :-
Struct Struct_type
{ type val 1; // members of structures type
val 2;
};
After defining structure we can create variables as given
Struct struct_type v1, v2, v3.

26) Difference between Structure and Arrays


Structure Arrays
1. Collection of heterogeneous types 1. Collection of homogeneous types of
of data i.e. different types of data. data i.e. same types
of data
2. A structure element component 2. An away it is referred by its position
of structure has a unique name. i.e. index.

27)Define file and its operation?


A file is a place on disk where group of related data are stored. C supports a number of
functions that have the ability to perform basic file operations,
Naming a file
Opening the file
Reading data from the file
Writing data to the file
Closing the file
1. Opening a File:
The general format of the function used for opening a file is
FILE *fp;
2. Closing the File:
f close(file -'pointer);
28)Reading a character from a file and writing a character into a file ( getc () and putc
()' functions)
The getc and putc functions are analogous to getchar and putchar functions and handle one
character at a time. The putc function writes the character contained in character variable c
to the file associated with the pointer fp1. ex putc(c,fpl); similarly getc function is used to
read a character from a file that has been open in read mode. c=getc(fp2).

29)Reading a integer from a file and writing a integer into a file ( getw() and putw()
functions) These are integer-oriented functions. They are similar to get c and putc functions
and are used to read and write integer values. These functions would be useful when we deal
with only integer data. The general forms of getw and putw are:
putw(integer,fp );
getw(fp);

30)What is the use of fscanf() and fprintf() functions?


The fprintf and fscanf functions are identical to printf and scanf functions except that they
work on files. The first argument of theses functions is a file pointer which specifies the file
to be used.
fprintf(fp,"control string", list);
fscanf(fp,"controlstring" ,list);

31) What is the use of C fgetc () and fputc() functions?


 fgetc() function is similar to getc() function. It also reads a character and increases the
file pointer position. If any error or end of the file is reached it returned EOF.
 fputc() function writes the character to the file shown by the file pointer. It also
increases the file pointer position.
32) What is the use of fgets() and fputs() functions:
 fgets() function reads string from a file pointed by file pointer. It also copies the string
to a memory location referred by an array.
 fputs() function is useful when we want to write a string into the opened file

You might also like