Viva Questions
Viva Questions
Q3. What do you mean by the Scope of the variable? What is the scope of the variables in C?
Ans: Scope of the variable can be defined as the part of the code area where the variables declared in
the program can be accessed directly. In C, all identifiers are lexically (or statically) scoped.
Q15. What is the purpose of printf() and scanf() in C Program?
Ans: printf() is used to print the values on the screen. To print certain values, and on the other hand,
scanf() is used to scan the values. We need an appropriate datatype format specifier for both printing
and scanning purposes. For example,
%d: It is a datatype format specifier used to print and scan an integer value.
%s: It is a datatype format specifier used to print and scan a string.
%c: It is a datatype format specifier used to display and scan a character value.
%f: It is a datatype format specifier used to display and scan a float value.
Q16. What is an array?
Ans. The array is a simple data structure that stores multiple elements of the same datatype in a
reserved and sequential manner. There are three types of arrays, namely,
One Dimensional Array
Two Dimensional Array
Multi-Dimensional Array
Q17. What is /0 character?
Ans: The Symbol mentioned is called a Null Character. It is considered as the terminating character
used in strings to notify the end of the string to the compiler.
Q18. What is the main difference between the Compiler and the Interpreter?
Ans: Compiler is used in C Language and it translates the complete code into the Machine Code in
one shot. On the other hand, Interpreter is used in Java Programming Langauge and other high-end
programming languages. It is designed to compile code in line by line fashion.
Q19. Can I use int datatype to store 32768 value?
Ans: No, Integer datatype will support the range between -32768 and 32767. Any value exceeding
that will not be stored. We can either use float or long int.
Basic C Programming Viva Questions
1) What do you mean by Hardware and Software?
All the electronic/electrical components and circuits used in a computer system are called hardware. A
computer is actuated and controlled with the help of computer programs called software.
4) What is Algorithms?
An algorithms refer to the step by step instructions written to solve any problem.
5) What is Flowchart ?
A flowchart is a diagrammatic or symbolic representation of an algorithms. It uses various symbols to
represent the operations to be performed.
6) Name the four basic data types in “C” language?
The four basic data types in “c” language are as follows
char – a character
int – an integer, in the range -32,767 to 32,767
long int – a larger integer (up to +-2,147,483,647)
float – a floating-point number
double – a floating-point number, with more precision and perhaps greater range than float
7) Describe at least five different format specifiers?
%d: -An integer whole number
%f: -a floating point number
%c: -a single character
%s: -a string of value of characters.
8) Define and explain scanf () function?
The Scanf () function can be used to get input into a program and it requires two arguments. First a
format specifier defines the type of data to be entered, then the name of the variable in which the input
will be stored. This scanf () function is responsible for giving input into the program.
9) Define and explain printf () function?
The printf() function is used to display/output values of variable in the monitor. The printf function
has general form: printf (“format specifiers”,variables)
10) What are the maximum and minimum possible ranges of values for long and short type?
If the int variable is created by default as a ‘long’ type it typically will have a possible range of values
from a maximum of +214748347 and a minimum of -2147483648. For ‘short’ type these are the
maximum and minimum values +327676 and minimum -32768.
(While answering this question you can specify the approximate value raised to power).
11) What is preprocessor?
The preprocessor is a program which is executed before the compilation of a source program written
by the user. The preprocessor directives begines with hash (#) followed by the command. e.g #include
– it is a directive to include file.
12) What exactly is a ‘variable scope’, ‘local variables’ and ‘global variables’?
The extent to which a variable is accessible in a program is called the ‘variable scope’. Variables
declared internally inside a function are known as ‘local’ variables.
Variables declared externally outside a function are known as ‘global’ variables.
13) What are signed values?
When an int variable is declared it can by default contain either positive of negative integer values.
These are known as ‘signed’ values. The range of positive values is determined by your system.
14) Define reserved words.
C programs are constructed from a set of reserved words which provide control and from libraries
which perform special functions. The basic instructions are built up using a reserved set of words,
such as main, for, if,while, default, double, extern, for, and int, to name just a few.
15) What is the purpose of type declaration in C ?
All variables used in a C program are declared using the appropriate data types to enable the compiler
to allocate the required number by bytes in RAM to store values of these variables in memory
16) What is identifier ?
An identifier is a name used to identify a variable, function, symbolic constsnt and so on.
17) Mention the different types of operators used in C ?
1. Arithmetic operator
2. Relational operators
3. Logical Operators
4. Increment and decrements operators
5. 5.Assignment operators
6. 6.Conditional operator
7. Bitwise oprators
18) What is Loop control statements ?
Loop control structures are used to execute and repeat a block of statements depending on the
value of a condition. There are 3 types of loop control statements in C
1. for loop
2. while loop
3. do – while loop
19) explain while loop .
A while loop has one control expression, and executes as long as that expression is true. The
general syntax of a while loop is
while( expression ){
statements
}
we use a while loop when a statement or group of statements which may have to be executed
a number of times to complete their task. The controlling expression represents the condition
20) explain for loop .
A for loop is used to execute and repeat a block of statements depending on a condition. The
syntax of a for loop is
for( ; ; )
{
statements
}
21) What do mean by network ?
Computer networking refers to connecting computers to share data, application software and
hardware devices. Networks allow sharing of information among various computers and
permit users to share files
22) List a few unconditional control statement in C.
1. break statement
2. continue statement
3. goto statement
4. exit() function
23) What is an array?
An array is a collection of values of the same data type. Values in array are accessed using
array name with subscripts in brackets[]. Synatax of array declaration is
data type array_ name[size];
24) What is Multidimensional Arrays?
An array with more than one index value is called a multidimensional array. To declare a
multidimensional array you can do follow syntax
data type array_ name[] [] []….;
25) Define string?
An array of characters is known as a string.for example
char st[8]; this statement declares a string array with 80 characters .
26) Mention four important string handling functions in C languages .
There are four important string handling functions in C languages .
1. strlen();
2. trcpy();
3. strcat();
4. strcmp();
The header file #include is used when these functions are called in a C program.
27) Explain about the constants which help in debugging?
A #if directive test can be offered with #else and #else if directives. This allows conditional
branching of the program to run sections of the code according to the result. Constants
defined with a #define directive can be undefined with the #undef directive. The #ifdef
directive has a companion directive #ifndef. These commands can be useful when debugging
problem code to hide and unhide sections of the program.
28) Define and explain about ! Operator?
The logical operator ! NOT is a unary operator that is used before a single operand. It returns
the inverse value of the given operand so if the variable “c” had a value of true then! C would
return value of false. The not operator is very much useful in C programs because it can
change the value of variables with successful iterations. This ensures that on each pass the
value is changed.
29) What is operator precedence?
Operator precedence defines the order in which C evaluates expressions.
e.g. in the expression a=6+b*3, the order of precedence determines whether the addition or
the multiplication is completed first. Operators on the same row have equal precedence.
38) How does the type float differ from double in C language ?
Float data type refers real number in single precision and has 6 decimal digits. It takes 4 bytes
in memory to refer values ranging from 3.4e-38 to 3.4e+38
Double data type also refers to real number but in double precision and has 12 decimal digits.
It takes 8 bytes of memory to refer values ranging from 1.7e-308 to 1.7e+308