You are on page 1of 24

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.
2) Mention the main components of a computer and their funtions.
CPU (cenral processing unit) – to process the data
Input Device – to enter the dat into the computer.
Output Device – to display / print results by the computer.
3) What is Operating System(OS) ?
An operating system is a collection of programs used to connect the user with the
hardware It has the set of programs which controls the operations of the hardware
components such as CPU, main memory, keyboard, monitor, printer and so on.
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 divices. 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.
30) Explain about the functions strcat() and strcmp()?
This function concatenates the source string at the end of the target string. Strcmp()
function compares two strings to find out whether they are the same or different. The
two strings are compared character by character until there is a mismatch or end of one
of the strings is reached, whichever occurs first. If in case two strings are identical, a
value of zero is returned. If there is no matches between two strings then a difference of
the two non matching values are returned according to ASCII values.

31) Define function


A function is a module or block of program code which deals with a particular task. Each
function has a name or identifier by which is used to refer to it in a program. A function
can accept a number of parameters or values which pass information from outside, and
consists of a number of statements and declarations, enclosed by curly braces { },
which make up the doing part of the object

32) Differentiate built-in functions and user – defined functions.


Built – in functions are used to perform standard operations such as finding the square
root of a number, absolute value and so on. These are available along with the C
compiler and are included in a program using the header files math.h, s tring.h and so
on.
User defined functions are written by the user or programmer to compute a value or
perform a task. It contains a statement block which is executed during the runtime
whenever it is called by the main program.
33) Distinguish between actual and formal arguments.
Actual arguments are variables whose values are supplied to the function in any
function call. Formal arguments are variables used to receive the values of actual
arguments from the calling program.

34) Explain the concept and use of type void.


A function which does not return a value directly to the calling program is referred as a
void function. The void functions are commonly used to perform a task and they can
return many values through global variable declaration.
35) What is recursion ?
A function calling itself again and again to compute a value is referref to as recursive
function or recursion. Recursion is useful for branching processes and is effective where
terms are generated successively to compute a value.
36) Mention the types of network.
A simple network consist of computers connected using nework interface cards,
networking software and network cables. There are two main networking arrangents

1. i) client / server – a powerful computer is used as the server which works as the
interpreter between the clients and helps sharing files.

ii)peer to peer – there is no server and all the workstations are treated equally.

37) what are Library functions?


Library functions are built in programs available along with the compiler which perform
some standard mathematical operations.
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
39) What is an operator and operand?
An operator performs an operation like addition, subtraction and so on and produce a
value. Variables and constants upon which operations are performed are called
operands.

40) What is RAM ?


RAM – Random Access Memory is a temporary storage medium in a computer. RAM is
a volatile memory i.e all data stored in RAM will be erased when the computer is
switched off.

41) What is ROM ?


ROM – Read Only Memory is permanent storage medium which stores start up
programs (operating system programs) and BIOS programs which are recorded by the
manfacturer of the compiler system. ROM is a non-volatile memory.

42) Define system software.


System software is a collection of programs which are used to assist the user to handle
the computer hardware like printer, disk and so on and execute the application
programs.
43) Define application software
application softwares are programs which are used to solve specific problems /tasks.
Examples include railway reservation, banking and so on.
44) What are control ststements ?
All the statements written in a program are executed from top to bottom one by one.
Control statements are used to execute / transfer the control from one part of the
program to another depending on a conditions.
45) What is Parallel Computation?
Computations that use multi-processor computers and/or several independent
computers interconnected in some way, working together on a common task.

 Examples: CRAY T3E, IBM-SP, SGI-3K, Cluster of Workstations.

46) Why use Parallel Computation?

 Computing power (speed, memory)


 Cost/Performance
 Scalability
 Tackle intractable problems

47) What does OpenMP stand for?


Short version: Open Multi-Processing
Long version: Open specifications for Multi-Processing via collaborative work between
interested parties from the hardware and software industry, government and academia.
48) Explain increment and decrements operators .
++ increment operator which add one to the value,

example : i++ (which adds one to i and results is scored back to)

— decrement operator which subtracts one from the value

example — i ( which subtracts one from i)

49) Mention the types of memory


Two major types of memory storage is primary memory and secondary memory.
Primary storage (or main memory or internal memory), often referred to simply as
memory, is the only one directly accessible to the CPU.
Secondary memory (or external memory) differs from primary storage in that it is not
directly accessible by the CPU. Some of the example for secondary memory includes
floopy disks, flash memory, mengetic tape, hard drives etc.

50) What are input and output device ?


Input and Output Devices: Input devices are the hardware that are used for providing
information to the computer like mouse and keyboard and output devices are the
hardware that are used for receiving information from computer like monitor, printer or
the sound system.

1. Who developed C language?


C programming language was developed at Bell Laboratories in
1972 by Dennis Ritchie.
2. What is the difference between C and C++?
 Even though C and C++ programming languages are belonging to
middle level languages, both are differed in below.
 C is structure/procedure oriented programming language whereas
C++ is object oriented programming language.
 C language program design is top down approach whereas C++ is
using bottom up approach.
 Polymorphism, virtual function, inheritance, Operator overloading,
namespace concepts are not available in C programming
language. Whereas C++ language supports all these concepts and
features.
 C languages give importance to functions rather than data.
Whereas C++ gives importance to data rather than functions.
 So, data and function mapping is difficult in C. But, data and
function mapping is simple in C++ that can be done using objects.
 C language does not support user define data types. Whereas
C++ supports user define data types.
 Exception handling is not present in C programming language.
Whereas exception handling is present in C++ language.
 C language allows data to freely flow around the functions. But,
data and functions are bound together in C++ which does not
allow data to freely flow around the functions.

3. Which level is C language belongings to?


 C language is belonging to middle level language.
 C language behaves as a bridge between machine level (low level)
Languages and high level languages.
 C language is more user friendly than machine level languages.
 And, C language support does not support all the concepts that
high level languages offer. So, C programming languages is called
as middle level language.

4. What are the types of errors occurred in C program?


There are four types of errors occurred during the program
execution.
 Syntax errors
 Runtime errors
 Logical errors
 Latent errors

5. What is meant by programming language?


 Programming language is nothing but a language designed to
communicate to machines through instructions and commands.
 Normally machines are computers. Programs are written using
some programming languages to control the behavior of
machines/computers and to make them to perform required tasks.
 Programming language example: Assembly language, C language,
C++ language, Java, C#, .NET, Python etc.
6.
What is structured programming?

 It is a programming techniques that assumes the disciplined use


of a few coding structures and the use of top down concepts to
decompose main functions into lower level components for
modular programming.
 The main aim of this technique is to improve the programming
process through better organization and with better programming
notations to facilitate correct and clear description of data and
control structures.

7. Is C a structured programming language?


Yes, C language is structured language.
8. C language has been developed in which language?
C language has been developed using assembly level language.
9. What is the difference between C and Java?
 C is structure/procedure oriented programming language whereas
Java is object oriented programming language.
 C language program design is top down approach whereas Java is
using bottom up approach.
 C language is middle level language whereas Java is high level
language.
 Exception handling is not present in C programming language.
Whereas exception handling is present in Java.
 Polymorphisms, virtual function inheritance, operator overloading,
namespace concepts are not available in C programming
language. Whereas Java supports all these concepts and features.

10. Whether C language is low level language, or


middle level language?
 The C language is a middle level language.
 It is called a middle level language because it has
features of high level language as well as low level
language.

11. What is modular programming?


 It is a programming technique that produces
relatively small, easily understandable computer
modules.
 A complex or large program is broken into number
of logically self contained modules.
 These modules may be written and tested
separately by number of programmers.
 Finally, the modules can be then put together to
form the complete program/system.

12. Is C language case sensitive?


Yes. C language instructions/commands/functions and everything
used in C program are case sensitive.
13. What is data type in C?
 Data types in C language are defined as the data storage format
that a variable can store a data to perform a specific operation.
 Data types are used to define a variable before to use in a
program.
 Size of variable, constant and array are determined by data types.

14. What is the difference between interpreter and compiler?


 Interpreters translate the high level language to machine level
language line by line
 Where as Compilers translate the entire program into machine
level language.

15. What is the difference between declaration and definition


of a variable?
 Declaration only identifies the data type of a variable whereas
definition causes the space to be reserved for the variable.
 Thus, declaration in a place where the nature of the variable is
stated but no storage is allocated whereas definition is the place
where the variable is created or assigned storage.

16. What is a program flowchart?


 A flowchart provides a visual representation of the step by step
procedure towards solving a given problem.
 Flowcharts are made of symbols, with each symbol in the form of
different shapes.
 Each shape may represent a particular entity within the entire
program structure, such as a process, a condition, or even an
input/output phase.

17.
What is the syntax for comments in C?

 Below is the syntax for comments in C. The characters or words or


anything which are given between "/*" and "*/", won't be
considered by C compiler for compilation process. These will be
ignored by C compiler during compilations.
 Syntax : /* your comments here */
18. List out some of C compilers?
There are so many compilers available in market for Windows
operating system and UNIX. We are listing some of them here for
your reference.
 AMPC
 CCS C Compiler
 ch
 clang
 cygwin
 Digital mars
 GCC compiler
 MikroC Compiler
 Portable C Compiler,Power C, QuickC, Ritchie C Compiler, Small–
C.

19. What is the difference between exit() and return() in C?


 exit() is a system call which terminates current process.
 exit() is not an instruction of C language.
 Whereas, return() is a C language instructions/statements and it
returns from the current function (i.e. provides exit status to
calling function and provides control back to the calling functions).

20. What is the difference between calloc and malloc?


calloc and malloc are used for dynamic memory allocation. calloc
initializes the memory locations to zero by default but malloc
memory contains garbage values.
21. What are the different types of modifiers in C?
There are five modifiers available in C language. They are
 short
 long
 signed
 unsigned
 long long

22. What is constant in C?


 Constants refer to fixed values. They are also called as literals.
 C constants are also like normal variables.
 But, only difference is, constant values can't be modified by the
program once they are defined.
 Constants may be belonging to any of the data type.

23. What are the types of constants in C?


There are many types of constants in C Programming are
 Integer constants
 Real or floating point constants
 Octal and hexadecimal constants
 Character constants
 String constants
 Backslash character constants

24. What is dangling pointers in C?


When a pointer is pointing to non existing memory location is
called dangling pointer.
25. What is the difference between rand(), random(), and
randomize()?
 random() - returns random number between 0 and one less that
its argument.
 rand () – returns successive pseudo random numbers in the range
0 to RAND_MAX.
 srand() – initializes the random number generator with a given
seed value.
 randomize() – initializes the random number generator with a
random value.

26. What is bebugging?


It is the process of injecting known bugs in a program in order to
train the students in debugging.
27. What is a compiler?
A compiler is a program that takes source code as its input, check
the entire program instruction by instruction for its grammatical
accuracy, and if the source code is grammatical accurate, then it
translates the program again instruction by instruction to machine
language and writes to the disk file.
28. What are all decisions control statements in C?
There are three types of decision making control statements in C
language. They are
 if statements
 if else statements
 nested if statements

29. What is mean by debugging?


Debugging is the process of locating and isolating the errors.
30. What is static function in C?
 All functions are global by default in a C
program/file.
 But, static keyword makes a function as a local
function which can be assessed only by the
program/file where it is declared and defined.
 Other programs/files can't access these static
functions.

31. What is meant by preprocessor?


Preprocessor is the program, that process our
source program before the compilation.
32. What is relocation?
Relocation means identifying the existing addresses of program
code and data.
33. What is a structured programming language?
A language is said to be a structural language if it meets the
requirements of structured programming.
34. Where auto local variables are stored?
These are stored in a stack. This stack is automatically maintained
by the system.
35. What is a subprogram/module?
 It is a program carrying out a particular function and which be
called by another program known as the calling program.
 A subprogram needs to be placed only once in memory and can be
called by the main program or other subprogram as many times
as the programmer wants.
 Also known by various names as function, subroutine or
procedure.

36. What are the differences between exit() and return


statement?
 First difference is that exit() is a function while return is a
statement.
 Second difference is that exit() function terminates the program
while return statement terminate the function.
 Third difference is that exit() function always return some value
where it is optional for return statement.

37.
What is token in C?

 C tokens are the basic buildings blocks in C language which are


constructed together to write a C program.
 Each and every smallest individual unit in a C program is known
as C tokens.

38. What are the types of C tokens?


C tokens are of six types. They are
 Keyword
 Identifiers
 Constants
 Strings
 Special symbols
 Operators

39. What are the different types of variables in C?


There are three types of variables in C
 Local variable
 Global variable
 Environment variable

40. What is environment variable in C?


 Environment variable is a variable that will be available for all C
applications and C programs.
 Once environment variables are exported, we can access them
from anywhere in a C program without declaring and initializing in
an application or C program.

41.
What is local variable in C?

 The variables which are having scope/life only within the function
are called local variables.
 These variables are declared within the function and can't be
accessed outside the function.

42. What are the types of I/O statements available in C?


There are two types of I/O statements available in C:
 Formatted I/O Statements
 Unformatted I/O Statements

43. What is global variable in C?


 The variables which are having scope/life throughout the program
are called global variables.
 A global variable is defined outside the main functions.
 So, this variable is visible to main function and all other sub
functions.

44. What is identifier in C?


 Each program elements in a C program are given a name called
identifiers.
 Names given to identify Variables, functions and arrays are
examples for identifiers.

45.
What is the difference between the expression "++a" and "a++"?

 With ++a, the increment happens first on variable a, and the


resulting value is used. This is called as Prefix increment.
 With a++, the current value of the variable will be used in an
operation. This is called as postfix increment.

46. What are the types of I/O statements


available in C?
There are two types of I/O statements available in
C:
 Formatted I/O Statements
 Unformatted I/O Statements

47. Do function prototypes get stored in


executable file?
 No. The compiler uses these functions prototypes at
the time of compilation.
 Therefore, once the program is compiled, they are
not required.
 Hence they are not stored in executable file.

48. Define pre–processor?


It is a program that processor the source code
before it passes to the compiler.

49. What is operator in C?

 The symbols which are used to perform logical and mathematical


operations in a C program are called C operators.
 These C operators join individual constants and variables to form
expressions.
 Operators, functions, constants and variables are combined
together to form expression.

50. What are the different types of operators in C?


C language offers many types of operators. They are
 Arithmetic operators
 Assignment operators
 Relational operators
 Logical operators
 Bit wise operators
 Conditional operators (ternary operators)
 Increment/decrement operators
 Special operators

51. What is bitwise operator in C?


 Bitwise operators are used to perform bit operations. Decimal
values are converted into binary values which are the sequence of
bits and bit wise operators work on these bits.
 Bit wise operators in C language are &(bitwise AND), | (bit wise
OR), ~ (bitwise OR), ^ (XOR), << (left shift) and >> (right shift).

52. What is the significance of storage class?


The storage class, in general, determines the scope and lifetime of
a variable, which in turn helps to economize the memory usage.
53. What is translation unit?
 A translation unit is a set of files seen by the compiler.
 It includes the source code under consideration and files that are
included such as header files and other disk files contain C code.

54. Can we make our own header files?


Yes. You can make your own header files and put the declarations
of functions and related constants and macros developed by you.
55. What are multidimensional arrays?
Multidimensional arrays are capable of storing data in a two or
more dimensional structure.
56. What are the key features or characteristics of C
languages?
The characteristics of C language are
 Reliability
 Portability
 Flexibility
 Interactivity
 Modularity
 Efficiency and Effectiveness

57. What is a file?


A File is a collection of related information that is permanently
stored on the disk and allows us to access and alter that
information whenever necessary.
58. What is a pointer?
Pointer is a variable which holds the address of another variable.
59. What are the uses of pointers?
 Pointers are used to return more than one value to the function.
 Pointers are more efficient in handling the data in arrays.
 Pointers reduce the length and complexity of the program.
 They increase the execution speed.
 The pointerssaves data storage space in memory.

60. What is enum in C?


 Enumeration is a data type that consists of named integer
constants as a list.
 It starts with 0 by default and value is incremented by 1 for the
sequential identifiers in the list.

61. What is the syntax for comments in C?


Below is the syntax for comments in C. The characters or words or
anything which are given between "/*" and "*/", won't be
considered by C compiler for compilation process. These will be
ignored by C compiler during compilations.
Syntax : /* your comments here */

62. What are reserved words?


 Reserved words are words that are part of the standard C
language library.
 This means that reserved words have special meaning and
therefore cannot be used for purpose other than what it is
originally intended for.
 Examples of reserved words are int, void and return.

63. What is the difference between getch() and getche()?


Both getch() and getche() are used to read single character there
is very little difference
 Both functions accept a character input value from the user.
 When getch() is used, the key that was pressed will not appear on
the screen. It is automatically captured and assigned to a
variable.
 While when getche() is used, the key that was pressed by the user
appears on the screen and is assigned to a variable.

64. What are actual arguments?


When you create and use functions that need to perform an action
on some given values, you need to pass these given values to that
function. The values that are being passed into the called
functions are referred to as actual arguments.
65. What is wild pointer in C?
Uninitialized pointers are called as wild pointers in C which points
to arbitrary (random) memory location. This wild pointer may lead
a program to behave wrongly or to crash.

66. Can a variable be both const and volatile?


 Yes. The const modifier means that this code cannot change the
value of the variable, but that does not mean that the value
cannot be changed by means outside this code.
 If a variable is both const and volatile, the two modifiers can
appear in either order.

67. List out some of C compilers?


There are so many compilers available in market for Windows
operating system and UNIX. We are listing some of them here for
your reference.
 AMPC
 CCS C Compiler
 ch
 clang
 cygwin
 Digital mars
 GCC compiler
 MikroC Compiler
 Portable C Compiler
 Power C
 QuickC
 Ritchie C Compiler
 Small- C

68. What is void in C?


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.
69. What is a program flowchart?
 A flowchart provides a visual representation of the step by step
procedure towards solving a given problem.
 Flowcharts are made of symbols, with each symbol in the form of
different shapes.
 Each shape may represent a particular entity within the entire
program structure, such as a process, a condition, or even an
input/output phase.

70. What are the advantages and disadvantages of a heap?


 Storing data on the heap is slower than it would take when using
the stack.
 However, the main advantage of using the heap is its flexibility.
That's because memory in this structure can be allocated and
remove in any particular order.
 Slowness in the heap can be compensated if an algorithm was well
designed and implemented.

71. Is it possible to create your own header files?


Yes, it is possible to create a customized header file. Just include
in it the function prototypes that you want to use in your program,
and use the #include directive followed by the name of your
header file.

72. What is the use of "# define" in C?


#define is a pre-processor directive which is used to define
constant value. This constant can be any of the basic data types.
73. What is NULL in C?
NULL is a macro which defined in C header files. The value of
NULL macro is 0. It is defined in C header files as below
#define NULL (void *) 0;
NULL is used for pointers only as it is defined as (void *) 0. It
should not be used other than pointers. If NULL is assigned to a
pointer, then pointer is pointing to nothing.
74. What is null pointer in C?
Null pointer is a pointer which is pointing to nothing. Null pointer
points to empty location in memory. Value of null pointer is 0. We
can make a pointer to point to null as below.
int * p = NULL;
char * p = NULL;

75. What happens when the user gives a command to run a


program?
The operating system first allocates the requisite amount of
memory to the program, then, through loader, loads the program
in the allocated memory, and then passes on the control to the
program. The program runs the supervision of the operating
system. When the program finishes its execution or some runtime
errors occurs, the operating system removes the program from
the memory.

76. What is file pointer in C?


 File pointer is a pointer which is used to handle and keep track on the files being
accessed.
 A new data type called FILE is used to declare file pointer. This data type is defined
in stdio.h file.
 File pointer is declared as FILE *fp. Where, 'fb' is a file pointer.
 fopen() function is used to open a file that returns a FILE pointer.
 Once file is opened, file pointer can be used to perform I/O operations on the file.
fclose() function is used to close the file.
77. What is the difference between memcpy() & strcpy()
functions in C?
memcpy() function is used to copy a specified number of bytes
from one memory to another. Whereas, strcpy() function is used
to copy the contents of one string into another string.
memcpy() function acts on a memory rather than value.
Whereas, strcpy() function acts on value rather than memory.

78. What are binary trees?


Binary trees are actually an extension of the concept of linked
lists. A binary tree has two pointers, a left one and right one. Each
side can further branch to form additional nodes, which each node
having two pointers as well.

79. What is stack memory allocation and dynamic memory


allocation?
 The compiler allocates the required memory space for a declared
variable. By using the address of a operator, the reserved address
is obtained and this address may be assigned to a pointer
variable. Since, most of the declared variable has static memory,
this way of assigning pointer value to a pointer variable is known
as static memory allocation. Memory is assigned during
compilation time.
 Dynamic memory allocation: it uses functions such as malloc() or
calloc() to get memory dynamically. If these functions are used to
get memory dynamically and the values returned by these
functions are assigned to pointer variables, such assignments are
known as dynamic memory allocation. Memory is assigned during
run time.

80
What is the difference between calloc and malloc?
.
calloc and malloc are used for dynamic memory allocation. calloc
initializes the memory locations to zero by default but malloc memory
contains garbage values.
81. What is FIFO?
In C programming, there is a data structure known as queue. In
this structure, data is stored and accessed using FIFO format, or
First In First Out. A queue represents a line wherein the first data
that was stored will be the first one that is accessible as well.

82. What is stack?


A stack is one form of data structure. Data is stored in stacks
using the FILO (First In Last Out) approach. At any particular
instance, only the top of the stack is accessible. Which means that
in order to retrieve data that is stored inside the stack, those on
the upper part should be extracted first. Storing data in a stack is
also referred to as a PUSH, while data retrieval is referred to as a
POP.
83. What are linked lists?
A linked list is composed of nodes that are connected with
another. In C programming linked lists are created using pointers.
Using linked lists is one efficient way of utilizing memory for
storage.
84. What is the different file extensions involved when
programming in C?
Source code in C is saved with .C file extension. Header files or
library files have the .H file extension.
Every time a program source code is successfully compiled, it
creates an .OBJ object file, and an executable .EXE file.
85. What is a nested loop?
A nested loop is a loop that runs
within another loop. Put it in
another sense, you have an inner
loop that is inside an outer loop. In
this scenario, the inner loop
performed a number of times as
specified by the outer loop. For each
turn on the outer loop, the inner
loop is first performed.
86. What is the difference between single equal "=" and double
equal "==" operators in C?
Single equal is an assignment operator used to assign the values
to the variables.
But, double equal is relational operator used to compare two
variable values whether they are equal or not.
87. What is "&" and "*" operators in C?
"*" Operators is used as pointer to a variable. Example: * a where
* is pointer to the variable a.
& operator is used to get the address of the variable. Example: &a
will give address of a.
88. What are formal parameters?
In using functions in a C program, formal parameters contain the values that
were passed by the calling function. The values are substituted in these formal
parameters and used in whatever operations as indicated within the main
body of the called function.
89. What is the difference between memcpy() and memmove()
functions in C?
 memcpy() functions is used to copy a specified number of bytes
from one memory to another.
 Memmove () function is used to copy a specified number of bytes
from one memory to another or to to overlap on same memory.
 Difference between memmove() and memcpy() is, overlap can
happen on memmove(). Whereas, memory overlap won't happen
in memcpy() and it should be done in non destructive way.

90. What is a newline escape sequence?


A newline escape sequence is represented by the \n character.
This is used to insert a new line when displaying data in the
output screen. More spaces can be added by inserting more \n
characters. For example, \n\n would insert two spaces. A newline
escape sequence can be placed before the actual output
expression or after.

91. Suppose a global variable and local variable have the same
name. Is it is possible to access a global variable from a
block where local variables is defined?
No. It is not possible in C. It is always the most local variable that
gets preference.
92. What is a sequential access file?
 When writing programs that will store and retrieve data in a file, it is
possible to designate that file into different forms.
 A sequential access file is such that data are saved in sequential order:
one data is placed into the file after another.
 To access a particular data within the sequential access file, data has to
be read one data at a time, until the right one is reached.

93. Is pointer arithmetic a valid one?


Pointer arithmetic is not valid one. Pointer addition, multiplication
and division are not allowed as these are not making any sense in
pointer arithmetic.

94. Is void pointer arithmetic a valid one?


Arithmetic operation on void pointer is not valid one. Void pointer
is a generic pointer. It is not referring int, char or any other data
type specifically. So, we need to cast void pointer to specific type
before applying arithmetic operations.

95. What is an endless loop?


An endless loop can mean two things. One is that is was designed
to loop continuously until the condition within the loop is met,
after which a break function would cause the program to step out
of the loop. Another idea of an endless loop is when an incorrect
loop condition was written, causing the loop to run erroneously
forever. Endless loops are oftentimes referred to as infinite loops.

96. What is pointer linking with operating system?


When we declare a null pointer it addresses the 0 address which
is the address of operating system so we cannot use that address
this is what the pointer is linked to OS.
97. Can you pass an entire structure to
functions?
Yes, it is possible to pass an entire structure to a
function in a call by method style. However, some
programmers prefer declaring the structure
globally, and then pass a variable of that
structure type to a function. This method helps
maintain consistency and uniformity in terms of
arguments type.

98. What is the difference between top down approach and


bottom up approach in programming languages?
 Top down approach and bottom up approach are involved in
software development. These approaches are not involved in
program execution. Structure/procedure oriented programming
languages like C programming language follows top down
approach. Whereas object oriented programming languages like
C++ and Java programming language follows bottom up
approach.
 Top down approach begins with high level design and ends with
low level design or development. Whereas, bottom up approach
begins with low level design or development and ends with high
level design.
 In top down approach, main() function is written first and all sub
functions are called from main functions.
 Then sub functions are written based on the requirements.
Whereas, in bottom up approach, code is developed for modules
and then these modules are integrated with main() function.
 Nowadays, both approaches are combined together and followed
in modern software design.

99. How do you convert strings to numbers in C?


You can write you own functions to do string to number
conversions, or instead use C's built in functions. You can use a to
f to convert to a floating point value, a to i to convert to an
integer value and a to l to convert to a long integer value.
100. What is the use of "goto" statement?
goto statement is used to transfer the normal flow of a program
to the specified in the program. Below is the syntax for goto
statement in C.
{
……..
goto label;
……
…….
LABEL :
statements;
}

You might also like