0% found this document useful (0 votes)
44 views

C Programming Viva Questions Answer

C programming viva questions cover topics like compilers, interpreters, assemblers, protocols, integrated development environments, instructions, data types, header files, functions, loops, operators, and more. Key functions include printf() for output, scanf() for input, and library functions stored in .lib files. Comments are used to add remarks to programs. Variables must be declared before use, and reserved words must be in lowercase.

Uploaded by

Vaishnav Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

C Programming Viva Questions Answer

C programming viva questions cover topics like compilers, interpreters, assemblers, protocols, integrated development environments, instructions, data types, header files, functions, loops, operators, and more. Key functions include printf() for output, scanf() for input, and library functions stored in .lib files. Comments are used to add remarks to programs. Variables must be declared before use, and reserved words must be in lowercase.

Uploaded by

Vaishnav Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

C Programming Viva Questions Answer

1. What is Compiler?
Answer: Compiler is a program that converts human readable
code (source code) into machine readable code, this process is called
compilation.
2. What is Interpreter?
Answer: Interpreter converts human readable code (source code)
into intermediate code and then this intermediate code is executed line
by line.
3. What is Assembler?
Answer: Assembler is a program that converts assembly level
language (low level language) into machine level language.
4. What is Protocol?
Answer: Protocol is nothing but a set of rules to be followed by a
programmer.
5. What is IDE in C?
Answer: IDE is nothing but integrated development environment.
IDE is a tool that provides user to create, compile and execute C
program. For example: Turbo C++, DevC++. These provide integrated
development environment.
6. What are Instructions?
Answer: In C instructions are the statements which tells computer
to perform the specific task.
7. What is C Programming Language?
Answer: C is a high level programming language. It is used to
develop system software and application software.
8. C language has been developed in which language?
Answer: C language has been developed using assembly language.
9. What is the difference between Text Files and Binary Files?
Answer: Text file contain data that can be easily understood by
human. It includes letters, numbers and other characters. On the other
hand, binary files contain 1s and 0s that only computers can interpret.
10. Is C a Structured Programming Language?
Answer: Yes, C language is structured language.
11. C is successor of which programming language?
Answer: B
12. What is Algorithm?
Answer: An algorithm refers to the step by step instructions
written to solve any problem.
13. What is Flowchart?
Answer: A flowchart is a diagrammatic or symbolic representation
of an algorithm. It uses various symbols to represent the operations to
be performed.
14. What are Library Functions?
Answer: Library functions are predefined functions and stored in
.lib files.
15. What is a Program?
Answer: A computer program is a collection of the instructions
necessary to solve a specific problem.
16. What is Object Code?
Answer: Compilation process translates source code into binary
language. This binary language code is known as object code.
17. What is Executable Code?
Answer: This code contains object code and definition of
predefined function from library. This code is written in binary
language.
18. What is void in C language?
Answer: Void is an empty data type that has no value. We use
void data type in functions when we don’t want to return any value to
the calling functions.
19. What is the meaning of Header File? Name some Header Files.
Answer: Header files contain declaration of predefined functions.
We can use any number of header files in our program as per the
requirement of predefined functions. Some header files are: stdio.h,
conio.h, math.h, stdlib.h, string.h, graphics.h
20. Can I create a customized Header File in C language?
Answer: It is possible to create a new header file. Create a file
with function prototypes that need to be used in the program. Include
the file in the ‘#include’ section in its name.
21. Explain the use of comma operator (,).
Answer: Comma operator can be used to separate two or more
expression.
22. What is the use of printf() function?
Answer: The printf() function is used to print the integer,
character, float and string values on to the screen or console. It is a
predefined function.
23. What is the use of scanf() function?
Answer: The scanf() function is used to take input from the user
or read some values from screen (or console). It is a predefined
function.
24. What is Console?
Answer: Console is known as output screen through which user
interacts with the source code.
25. What is #include?
Answer: It is a pre-processor directive. It is used to include any
header file in our program.
26. What is case sensitivity in C language?
Answer: Case sensitivity means upper case and lower case letters
are treated differently in C language.
27. Who designed C Programming Language?
Answer: Dennis M Ritchie
28. What is Debugging?
Answer: Debugging is the process of identifying errors within a
program.
29. What is Syntax Error?
Answer: Syntax errors occur at the time of compilation. It comes
when rules of programming language are not followed properly.
30. What is Logical Error?
Answer: Logical errors occur at the time of execution. It comes
when logics are not properly implemented in the program.
31. Why we use void keyword before main()?
Answer: Void is a data type. We can use any data type before
main(). The data types are used to denote return type of main()
function. If we are using void then it gives instruction to compiler that
main() function will not return any value.
32. It is possible to have more than one main() function in a C
program?
Answer: The function main() can appear only once. The program
execution starts from main() function.
33. Can the curly brackets{} be used to enclose a single line of code?
Answer: Curly brackets{} are mainly used to group several lines of
code. It will still work without error if you used it for a single line. Some
programmers prefer this method as a way of organizing code to make it
look clear, especially in conditional statement.
34. Can a program be compiled without main() function?
Answer: Yes, it can be but cannot be executed, as the execution
require main() function definition.
35. Why we use clrscr() function?
Answer: It is used to clear console or screen. It is declared in
conio.h file. It is predefined function.
36. What are Comments?
Answer: Comments are a great way to put some remarks or
description in a program. It can serve as a reminder on what the
program is all about. Comments begin with /* and ended by */
characters. It can be single line, or can even several lines. It can be
placed anywhere in the program.
37. What do you mean by Syntax?
Answer: Syntax means predefined rules of any programming
language.
38. What is structure of C program?
Answer: C program contains documentation section, link section,
definition section, global declaration section, main function and other
user defined functions.
39. Can we declare variable anywhere in C program?
Answer: No.
40. What are Format Specifiers? Why we use it?
Answer: Format specifiers are used to specify type of value which
we are going to read through scanf() function and to print through
printf() function. Some format specifiers are: int – %d, flaot – %f, char –
%c.
41. What is Garbage Value?
Answer: Garbage value means unused value. When we declare a
variable compiler automatically provides some value which is useless
for programmer so this value is known as garbage value.
42. What is the difference between getch() and getche()?
Answer: The getch() function reads a single character from the
keyboard. It doesn’t use any buffer, so entered data will not be
displayed on the output screen.
The getche() function reads a single character from the keyword, but
data is displayed on the output screen. Press Alt+f5 to see the entered
character.
43. Why is C called a mid-level programming language?
Answer: C is called a mid-level programming language because it
binds the low level and high -level programming language. We can use
C language as a System programming to develop the operating system
as well as an Application programming to generate menu driven
customer driven billing system.
44. What is the difference between the = symbol and == symbol?
Answer: The = symbol is often used in mathematical operations. It
is used to assign a value to a given variable. On the other hand, the ==
symbol, also known as "equal to" or "equivalent to", is a relational
operator that is used to compare two values.
45. What is || operator and how does it function in a program?
Answer: The || is also known as the OR operator in C
programming. When using || to evaluate logical conditions, any
condition that evaluates to TRUE will render the entire condition
statement as TRUE.
46. Not all reserved words are written in lowercase. TRUE or FALSE?
Answer: FALSE. All reserved words must be written in lowercase;
otherwise the C compiler would interpret this as unidentified and
invalid.
47. What is the difference between the expression "++a" and "a++"?
Answer: In the first expression, the increment would happen first
on variable a, and the resulting value will be the one to be used. This is
also known as a prefix increment. In the second expression, the current
value of variable a would the one to be used in an operation, before the
value of an itself is incremented. This is also known as postfix
increment.
48. What is wrong with this program statement? void = 10;
Answer: The word void is a reserved word in C language. You
cannot use reserved words as a user-defined variable.
49. Is it possible to have a function as a parameter in another
function?
Answer: Yes, that is allowed in C programming. You just need to
include the entire function prototype into the parameter field of the
other function where it is to be used.
50. What is recursion in C?
Answer: When a function calls itself and this process is known as
recursion. The function that calls itself is known as a recursive function.
51. Differentiate between for loop and a while loop? What are it
uses?
Answer: For executing a set of statements fixed number of times
we use for loop while when the number of iterations to be performed is
not known in advance we use while loop
52. What are built in functions?
Answer: The functions that are predefined and supplied along
with the compiler are known as builtin functions. They are also known
as library functions.
53. What is typecasting?
Answer: Typecasting is a way to convert a variable/constant from
one type to another data type.
54. What is void in C?
Answer: Void is an empty data type that has no value. We use
void data type in functions when we don't want to return any value to
the calling functions.
55. What is token in C language?
Answer: Each and every smallest individual unit in a C program is
known as tokens.
56. What are operators?
Answer: Operators are symbol which take one or more operands
or expression and perform arithmetic or logical computation.
57. What are operands?
Answer: Operands are variables or expressions which are used in
operators to evaluate the expression.
58. What are expressions?
Answer: Combination of operands and operators from an
expression.
59. Which bitwise operator is suitable for checking a particular bit is
ON or OFF?
Answer: Bitwise AND operator.
60. Can we assign a float variable to a long integer variable?
Answer: Yes, with loss of fractional part.
61. What is operator precedence?
Answer: Operator precedence defines the order in which C
evaluate expressions.
62. What is associativity?
Answer: The operators of the same precedence are evaluated
either from ‘left to right’ or from ‘right to left’, depending on the level.
This is known as the associativity property of an operator.
63. What is the difference between pre increment and post increment
operator?
Answer: Pre increment operator is used to increment variable
value by 1 before assigning the value to the variable. Post increment
operator is used to increment variable value by 1 after assigning the
value to the variable.
64. What is constant?
Answer: Constant is a value that does not change during the
program execution. A constant used in C does not occupy memory.
65. What do you mean by a variable?
Answer: Variables are simply names used to refer to some
location in memory, a location that holds a value with which we are
working.
66. What is a keyword?
Answer: Keywords are building blocks for program statements
and have fixed meanings and these meaning cannot be changed
67. What is difference between declaration and definition?
Answer: During declaration we just specify the type and no
memory are allocated to the variable. But during the definition, an
initial value is assigned and memory is allocated to the variable.
68. What is loop?
Answer: Loops are used to repeat a block of code.
69. What is nested loop?
Answer: A nested loop a loop within loop, an inner loop within
the body of an outer loop.
70. What is infinite loop?
Answer: A loop running continuously for an indefinite number of
times is called the infinite loop.
71. What is break statement?
Answer: The break statement is used to exit the current loop
before its normal ending.
72. Which keyword is used to perform unconditional branching?
Answer: goto.
73. What is the use of goto statement?
Answer: goto statement is used to transfer the normal flow of a
program to the specified label in the program.
74. Every loop control structure uses three important parts, what are
those?
Answer: 1) Initialization: It provides beginning value of loop. 2)
Termination condition: Termination condition specifies the ending of
the loop. 3) Increment/Decrement: It increases or decreases loop
counter.
75. What is an array?
Answer: An array is a collection of values of the same data type.
76. What are merits of array in C?
Answer: We can easily access each element of array. Not
necessity to declare too many variables. Array elements are sorted in
continuous memory location.
77. What are demerits of array in C?
Answer: Wastage of memory space. We cannot change size of
array at the run time. It can store only similar type of data.
78. What is the meaning of base address of the array?
Answer: The starting address of the array is called as the base
address of the array.
79. Can array subscripts have negative value in C?
Answer: No, array subscripts should not have a negative value.
Always, it should be positive.
80. Why array index always start with 0?
Answer: If we start array index by 1 then we will not be able to
access first location of an array.
81. What is stream?
Answer: A stream is a source of data or destination of data that
may be associated with a disk or other Input/Output (I/O) device.
82. What is source stream or input stream?
Answer: The source stream provides data to a program and it is
known as input stream.
83. What is destination stream or output stream?
Answer: The destination stream receives the output from the
program and is known as output stream.
84. What is function?
Answer: A large program is subdivided into a number of smaller
programs or subprogram. Each subprogram is called function. A
function is a set of statements to perform a specific task.
85. What is an argument?
Answer: An argument is an entity used to pass data from the
calling function to a called function.
86. What are formal arguments?
Answer: Formal arguments are the arguments available in the
function definition.
87. What are actual arguments?
Answer: Actual arguments are available in the function call.
88. How many types of functions are there in C language?
Answer: There are two types of functions: 1) predefined function,
2) User defined function.
89. What is the importance of user defined functions?
Answer: 1) Reusability of code. 2) Debugging becomes easy and
fast. 3) Compilation and execution time is reduced.
90. What is the default function call method?
Answer: By default the functions are called by value.
91. How many parts are there in every function?
Answer: There are three parts in every function: 1) Function
Declaration, 2) Function Calling, 3) Function Definition.
92. In header files whether functions are declared or defined?
Answer: Functions are declared within header file and defined in
library (lib).
93. What is prototype of a function?
Answer: Prototype means function’s declaration. It tells return
type, function name, and arguments type.
94. How many arguments can be passed to a function in C?
Answer: Any number of arguments can be passed to a function.
There is no limit on this. Function arguments are stored in stack
memory rather than heap memory. Stack memory allocation is
depending on the operating system. So, any number of arguments can
be passed to a function as much as stack has enough memory. Program
may crash when stack overflows.
95. Can we have variable with same name in different functions?
Answer: Yes.

You might also like