Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 32

1. What is a source file?

A source file is a collection of set of instructions designed to perform a particular task. Source
file is primarily used as input to the Translator that produces an executable file (i.e., it is
compiled or interpreted).

[ Supraja-S2]

2. What is a header file?

A header file is a collection of function declarations. A header file can also contain constants,
global variables, macro's that needs to be shared by many functions. A source file can make use
of the header file by including it.

[Ramya-s2]

3. what is an object file?

An obect file is a binary file containing machine language instruction


where compiler has not yet linked to the libraries. So, usually we get an
object file just before linking to the libraries. The object file is of .o
extension.

[Nilesh-s2]

4 .What is an executable file?

An executable file is a binary file which can't be readable by human because


it has been compiled. Once an object file is linked with the library by the
compiler then we get an executable file which can be executed on the
appropriate platform. Common executable files are .EXE , .BAT , .COM , .BIN.

[Priya-S2]

5.What is the naming convention of the ‘C’ source file?


We should choose meaningfull names to our source file..
The source file name can consist of letters, digits and special characters, followed by dot and a
letter c.
It is a compulsion that the last two characters of the source file should be dot c.
Examples of valid source file names are :
Add.c
Bubble_sort.c
[sharath kumar-s2]

6.What is the convention of header file as per c89 standard?


The header file should have a valid name.
There is no compulsion that there should be a .h extension .
[vinay-s2]

7. Give the difference b/w object file and executable file ?


Both are binary files but the differences between those is :-
We can execute an executable file while we cannot execute an object
file since external references has not been resolved.

[Girish-s2]

8. What are function prototypes/declarations.


A function prototype consists of a function name, argument type and return type.

Prototypes must be terminated with a semicolon.

Ex: return_type function_name(arguments_type);

The compiler uses the information in a function prototype for type checking.

Prototypes are optional in C89 Std.

It is recommended that the prototypes appear before use or in header files.

[vivek-S2]

9. Where does the execution of a ‘C’ program begin ?


main() serves as the starting point for program execution.
[PRIYANKA-S2]
10. Write the prototype of main on unix platform ?
> int main(int , char * [ ]);

> The first argument is of the type integer,it is usually referred as argc as it keep the argument
count. It contains the number of arguments passed to the program from the command line,
including the name of the program.
>The second argument is an array of character pointers. It contains all the command-line
arguments. It is usually referred as argv. argv[0] holds the name of the program. Argv[1] holds
the second command line argument (if any) and so on.

[sneha,s2]

14. List the difference b/w malloc() & calloc() ?


Ans:1. Malloc gives uninitialized memory where as calloc gives initialized memory.

15.What are library functions ?


Ans: Library functions are pre-compiled programs provided by the compiler developer, which a
programmer can use in his/her program.

16.What are the functions of the linker.


Ans: linker is responsible for resolving external linkage

[Santosh-S2]

17. What does #include <stdio.h> mean?

#include is a pre-processor directive. It includes the file named stdio.h which is header file into the
current source file. The angle brackets specifies the pre-processor to search the file in standard
directory .
18.What does #include “stdio.h” mean?

#include is a pre-processor directive. It includes the file named stdio.h which is header file into the
current source file. The “ ” (double quotes) specifies the pre-processor to start the search
from the current directory . If the file is not present in the current directory then search
continues with standard directory

19.List the main translation units in a compilation process?

Extensions are platform dependent.

1. Pre-processor: Takes the source file as input


executes the instructions started with #

removes the comments

squeezes spaces and blanks

changes are made to the same source file.

2. Compiler: input is pre-processor output


after successful compilation i,e if there is no syntax and semantic error
then the compiler produces object file (.obj)

3. Linker: input is .obj file links the standard library files into the assembly file. After successful
linking process executable file is created (a.out)
[Dileep Raj-S2]

20. What is a pre-processor ?


• The preprocessor is a text processor that manipulates the text of a source file as part of the
first phase of translation before they are
passed to the compiler.
• the main responsibilities of preprocessor are acting upon the instruction that start with #,
filtering comments, squeezing empty lines and spaces
[Girish-S2 and Pavan-S2]
What does #error mean?
A preprocessor line of the form
#error token-seqopt
Cause the processor to write a diagnostic message that includes the token sequence.
Ex.
#include<stdio.h>
#ifndef Fun
#error “Fun is not defined.”
#endif
Int main()
{
Char a[]=”hello”;
Printf(“Given String:%s”,a);
Return 0;
}
This code throw an error if “Fun” is not defined at the preprocessing time and will not compile &
gives an error message along with the defined token-seq(i.e. “Fun is not defined” in this case ) .
If the “Fun “ is defined then it will compile successfully with-out any error.
[Ankit Jain-S1]

21. What are the responsibilities of the compiler?


Compiler is a translator which takes source file as input which is a high level language

And converts it into low level language ,it also checks for syntax and schematic errors

, it converts source file into an executable file if no errors present , if present if will display errors

[Rudrappa-s2]

23. Give the process layout on unix.

STACK

HEAP

DATA
SEGMENT

TEXT
SEGMENT
Typical logical memory layout of a process

Process Layout:

➢ Text segment /Code segment: It contains executable instructions. It has a


fixed size and is usually read-only.

➢ Data segment: It contains the global variables and static variables.

➢ Stack: All automatic variables are stored into stack area. It follow LIFO data-
structure. Stack is used for temporary storage of data.

➢ Heap: The heap area is used for dynamic memory allocations. It is managed by
the programmer using memory management functions.

[Priyanka, Sneha-s2]

24. What gets stored in stack?

• Stack segment is one of the sections of a program in memory.


• Stack (LIFO) is the data structure used to store the local variables
of a function.
[Nandini-S2]

25. What get stored in Data Segment?


• Data segment is one of the sections of a program in memory.
• Data segment contains the global variables and static variables.

[Sushmita Mazumdar-S2]
26. What is heap?
The heap is the section of computer memory (memory segment) where all the variables
created or initialized at runtime are stored.

The heap is extremely important because it is available for use by applications during
execution using the C functions malloc (memory allocate) and free. The heap allows
programmers to allocate memory when needed and free it when not required. Thus it is the
programmer’s responsibility to manage heap.

[Ramya-S2]

27. What is a static function?


Functions whose scope is limited within the current source file are said to be static functions.
By default functions have external scope the keyword static is used to reduce its scope to
internal. This is achieved by prefixing keyword static in declaration and definition of the
function.

[Siva-S2]

28. How many storage class we have?


There are two storage classes namely:-

1. Automatic
2. Static

Several keywords, together with the context of an object’s declaration, specify its storage class.

[Priya-S2]

29. What does storage class define?

The storage class defines the lifetime of an object i.e. It decides when the variable comes
into existence and when it gets destroyed.
[Priya-S2]

30.List the storage class specifiers?


The storage class specifiers are:

● auto

● static

● register

● extern and

● typedef.

[Ramya-S2]

31. List data-type modifiers.


1. Signed
2. Unsigned
3. Short
4. Long

32. List data-type Qualifiers?


1. Constant
2. Volatile

33. What is the default storage class of functions?


Extern

34. What is a void pointer?


void pointer is popularly known as generic pointer, is declared using the key word void it
means that it’s type is not known at the time of declaration ,hence it has to be
appropriately type casted when dereffencing .
Any pointer can be cast to void * and back again without loss of information.

35. List the restriction of the void pointer?


1. we can’t perform pointer arithmetic on void pointers without typecasting
2. We can’t dereference a void pointer.

[Santosh-S2]

36. How many values does a function return?


Function can return only one value .
37. Can a function be declared as static what it means?
Yes we can declare a function as static , this indicates that the function has
internal linkage.

38.Can a variable be declared both as const and volatile ex: const


volatile int i. What does it mean?
Yes we can declare, in the above example int i is volatile and read only.
Volatile keyword is intended to prevent the compiler from applying
any optimizations on the code inherent the attributed variable that
would be otherwise altered.

39.What is the storage class of local variables?


Storage class for local variables is automatic.

40.What is a macro?
Macro is a #defined constant, which when used in the code, the preprocessor will
replace the macro with its replacement text. It is a convention that all macros or #defined constants are
in uppercase.

[Mujeeb-S2]

41. What are function like macros?


We can also define macros with arguments, they look like a functionl.
These are called function-like macros. To define a function-like macro, we use the `#define'
directive, with a pair of parentheses immediately after the macro name.
#define lang_init() c_init()

#define SQUARE(z) ((z) * (z))

42. List the standard macros?


The standard predefined macros are specified by the relevant language standards, so they are
available with all compilers that implement those standards. Older compilers may not provide all
of them. Their names start with double underscores and end with double underscores.

__FILE__
__LINE__
__DATE__
__TIME__
__STDC__

43. What is assert ?


The macro assert() can diagnose program bugs. It is declared in assert.h and its prototype is
void assert(int expression);
The argument expression can be anything you want to test--a variable or any C expression. If
expression evaluates to TRUE, assert() does nothing. If expression evaluates to FALSE, assert()
displays an error message on stderr and aborts program execution.
If the macro NDEBUG (which stands for "no debugging") is defined, the assert() macros will be
ignored.

#include <assert.h>
main()
{
int x;
printf("\nEnter an integer value: ");
scanf("%d", &x);
assert(x >= 0);
printf("You entered %d.\n", x);
return(0);
}
Enter an integer value: -1
Assertion failed: x, file vivek.c, line 7
Abnormal program termination.

44.What are identifiers?


"Identifiers" or "symbols" are the names we supply for variables, types, functions, and labels in
our program. Identifier names must differ in spelling and case from any keywords. We create an
identifier by specifying it in the declaration of a variable, type, or function. A special kind of
identifier, called a statement label, can be used in goto statements. Once declared, we can use the
identifier in later program statements to refer to the associated value. The first character of an
identifier name must be a non-digit (that is, the first character must be an underscore or an
uppercase or lowercase letter). ANSI allows six significant characters in an external identifier's
name and 31 for names of internal (within a function or block) identifiers.

45. What is Lvalue?


The lvalue is located on the left side of an assignment statement(expression). The lvalue
expression must reference a storable variable in memory. It cannot be a constant. A lvalue is
simply the address value where the value assigned to a variable is to be stored. All lvalue can be
rvalue but all rvalue can not be lvalue.

Example for the lvalue:

int i=5;

now ++i++;

first it will increament the value of i as it is pre-increamnet to 6.


now the expression looks like 6++;

how it is possible to increament a one number in this case 6++;


the compiler trying to find out where is the variable .... here it is
a number that is why it will ask for the lvalue required.

[VIVEK, S2]

46. What is non-modifiable Lvalue?


An lvalue is something that can appear on the left side of an expression, in other words
something that can be assigned.

A non modifiable lvalue is a constant object.

For e.g.: const int a; // a is non modifiable value.

a = 10;

a++; // here we are trying to change the value of ‘a’

which will give compiler error

In GCC compiler error can be like this “Increment of read –only variable a”.

[Sushmita Mazumdar-S2]

47. What is Rvalue?


The objects that can appear on the right side of the expression are called an Rvalue.

E.g.: E1=E2; //Where E2 indicates the rvalue.

[Nandini.S-S2]

48. Broadly classify errors?


Errors can be broadly classified into two categories as follows:

● Compiler Error: These errors occur at compile time. For example:

➢ Syntax Errors: Error due to missing colon, semicolon, parenthesis, etc. Syntax is the
way in which we construct sentences by following principles and rules.

➢ Semantic Errors: Using an undeclared variable.


➢ Linker Errors: These are errors generated when the executable of the program
cannot be generated. This may be due to wrong function prototyping, incorrect
header files.

● Runtime Errors: These errors occur at runtime. For example:

➢ Segmentation Faults: occurs due to buffer overflow, using uninitialized


pointers, dereferencing null & void pointers

➢ Divide by Zero

49. When do we get Lvalue error. Give an example.


Lvalues are objects which may appear on the left side of an assignment.

For example, a variable is an lvalue and a constant is not an lvalue,

'x=5' is legal because ‘x’ has an valid address

'5=x' (or '5=3') is not legal because ‘5’ is constant and has no address.

[ Priyanka-S2 ]

50. What is segmentation fault ?


A segmentation fault occurs when a program attempts to access a memory location that
it is not allowed to access.

[Sneha – S2]
51. List the various reasons for segmentation fault?

-Attempt to write which has read-only permission

-A buffer overflow

-Using uninitialized pointers

-Dereferencing NULL pointers and void pointers

-Attempting to access memory that the program does not own

[Rashmita,S2]

52.Explain typecasting?
Typecasting is a way to make a variable of one type to another using typecast operator.
Eg: void *ptr;
int i=10;
ptr=&i;
printf(“%d”,*(int*)ptr);
[Priya-S2]

53. List the different types of typecasting?


The two different types of typecasting are:

● Implicit typecasting and

● Explicit typecasting.

[Supraja-S2]

54. What are the different types of integer constants?


Integer constants are of three types namely,
1.Decimal,
2.Hexadecimal,
3.Octal.

55. What is a string literal?


String literal is a collection of characters given within double quotes (“… ”).It is also
called as string constant. It will be automatically truncated with NULL(‘\0’) character.

[Ramya-S2]

56.How do you define a character constant?


Character constant is defined by placing a character or a sequence of characters between single quote
marks:
'a'
'b'

57. Where are string literal stored in memory?


In the read only segment(text segment).

58. How do you separate the interface from implementations?


In the C language, a good way to separate interface from implementation is to put the interface in a
`header file' with suffix .h(.h is not compulsory), and the implementation in a source file (with
suffix .c).

59. Give the difference b/w constant pointer and pointer to a constant?
Explain with an example.
In case of constant pointer the pointer cannot be reinitialized, where as in pointer to a constant the object
to which the pointer is pointing to is constant.
Ex: constant pointer
int *const p;
the const keyword should be between star(*) and the pointer name.

Pointer to a constant
const int* p;
The const keyword can be either before or after data type.

const types are initialized at the time of declaration.

60. What is recursion?


Recursion is a method in which a function calls(invokes ) itself directly.
[Sharath kumar-s2]

61.List the different types of recursions?


● Head Recursion.
● Mid Recursion.
● Tail Recursion.

62. List the different (MMF) Memory Management functions.


The different memory management functions are

● malloc ().
● calloc ().
● realloc ().
● free ().

61. What are command line arguments?


The arguments given on command line are called command line arguments.

Command line arguments are passed when executing a program. Command-line arguments are
given at the prompt separated by space. Command line input is treated as a string.

62. How do you write a function to take variable number of arguments? List
its restrictions?
Return type function name (known type, ...)
It can have any number of known types of arguments and eclipse (…) will be the last
argument in variable length argument list.
Restriction: In the argument list there should be at-least one known argument.
… should be the last argument if the function takes many aguments

[Amar-S2]

65. What is the prototype of printf()?


Ans: The prototype of printf is : int printf (const char *format, ...);

[ajay-s2]
66. What does printf() return?
Ans: Return type of printf function is an integer . On success it return’s the no of character printed
on the o/p screen. On failure it will return -1.

The prototype of printf is : int printf (const char *format, ...);

For eg: printf(“ajay”); the return integer value is 5.

[ajay-s2]

67. What does stdio.h contain ?

The abbreviation of stdio is standard input output.

The stdio.h is having declarations of standard library I/O functions , some standard
macros and structure templates .

Eg: printf(),scanf(),NULL,FILE.

[ajay-s2]

68. What is a node ( self referential structure ) ?


Ans : A node is a data structure which holds the data and the address and if the address is a
pointer of its own type it is called self referential structure .

[ajay-s2]

69. List the features of arrays ?


The feature of array is any array elements can be indexed .

[ajay-s2]

71.List the different types of functions?


Functions can either be of built in or user-defined.
There are broadly classified into 5 types as below:
• Function with no arguments and no return values.
• Function with arguments and no return values.
• Function with arguments and return values.
• Function with no arguments and return values.
• Function which returns multiple values (variable number of
arguments).

[Nandini.s s2]

72.How are characters stored in memory?


Binary representation of ASCII equivalent code of the corresponding character is stored in
the memory.

[Sushmita Mazumdar –S2]

73. How are integers stored in memory.


Integers are stored in their binary representation.

[Sneha-S2]

74. How are negative numbers stored ?


Signed negative numbers are stored in memory as two's Complement form.

Two’s complement is obtained by first finding the 1's complement and then adding
1 to the 1's complement .

Example: if the number is -1. Integer 1 in binary form is 0001.

1110 - 1’s complement

+ 1 - adding 1 to 1,s complement

Result 1111 - 2’s complement form

1111 will be a negative number coz the MSB is used to know whether the number is
actually negative or a positive. If the MSB is 1 it's treated as negative and if 0 it's
treated as positive.
[ Priyanka – S2 ]

75. How are floats stored in memory?


IEEE floating point numbers have three basic components:
• the sign,
• the exponent,
• And the mantissa.
• The mantissa is composed of the fraction and an implicit leading
digit .The exponent base (2) is implicit and need not be stored.

• The following figure shows the layout for single (32-bit) precision
floating-point values. The number of bits for each field are shown
(bit ranges are in square brackets):
sign exponent fraction bias
Single precision 1[31] 8[30-23] 23[22-00] 127

• The sign bit


• 0 denotes a positive number.
• 1 denotes a negative number.

• The exponent
• The exponent field needs to represent both positive and negative
exponents.
• To do this, a bias is added to the actual exponent in order to get
the stored exponent.
• For IEEE single-precision floats, this value is 127.
Thus, an exponent of zero means that 127 is stored in the exponent
field.
Exponents of -127 (all 0s) and +128 (all 1s) are reserved for special
numbers

• The mantissa
• The mantissa, also known as the significant, represents the
precision bits of the number. It is composed of an implicit leading
bit and the fraction bits.
• The mantissa is composed of the fraction and an implicit leading
digit .The exponent base (2) is implicit and need not be stored.
• To find out the value of the implicit leading bit, consider that any
number can be expressed in scientific notation in many different
ways.
For example, the number five can be represented as any of these:
5.00 × 100
0.05 × 102
5000 × 10-3
• Normalized form
5.00 × 100
0.05 × 102
5000 × 10-3
• In order to maximize the quantity of representable numbers, floating-
point numbers are typically stored in normalized form.
• This basically puts the radix point after the first non-zero digit.
• In normalized form, five is represented as
5.0 × 100.
• In base two, since the only possible non-zero digit is 1. We can
just assume a leading digit of 1, and don't need to represent it
explicitly.
• As a result, the mantissa has effectively 24 bits of resolution, by
way of 23 fraction bits.

• Special values
• Not A Number: The value NaN is used to represent a value that does
not represent a real number.
• NaN's are represented by a bit pattern with an exponent of all 1s
and a non-zero fraction.
• There are two categories of NaN:
QNaN (Quiet NaN) and
SNaN (SignallingNaN).

E.g.:Converting decimal real No to Floating point format.


Take the decimal part and convert it to base 2 system.
• Ex: 12.375
• First take 12 get it binary representation (1100)
• We see that (0.375)10 can be exactly represented in binary as
(0.011)2.
• Therefore (12.375)10 = (12)10 + (0.375)10 = (1100)2 + (0.011)2 =
(1100.011)2
• Finally we can see that :
• From which we deduce :
• The exponent is 3 (and in the biased form it is therefore 130 = 1000
0010 )
• The fraction is 100011 (looking to the right of the binary point)
• From these we can form the resulting 32 bit IEEE 754 binary32 format
representation of 12.375 as:
0-10000010-10001100000000000000000

• Special values

[Nandini.s s2]

76. What is the difference between variable and a constant?


Variable: A variable is an object whose value can be assigned and varied during the
execution of the program.

Constant: A constant value is the one which does not change during the execution of a
program.
[Supraja-S2]

77.what is size_t? List any two library function which make use of
it?
Size_t is an unsigned integer type.

fread ,malloc,calloc,strlen, fwrite are the library functions


which has the make use of it.

size_t fread(void *ptr,size_t size,size_t nobj,FILE *stream)


size_t fwrite(const void *ptr,size_t size,size_t nobj,FILE *stream)

[Rashmita-S2]

78. What is Precedence?


Precedence is a rule used to unambiguously clarify which operation should be performed
first in a given mathematical expression.

[Siva-S2]

79. When does associativity come in picture?


When an expression involves operators having same precedence then associativity come in
picture.

80.What does the text segment contain?


A code segment, is known as a text segment or simply as text contains all the instructions
contained in the source code.

81. List the features of %(modulus) operator?


● Modulus operator is a binary operator which works with two operands of integral
type .
● If the operands are signed the result always takes the sign of numerator.
● If numerator < denominator the result will be equal to numerator.
[Sharath kumar-s2]
82. Classify the operators based on the operands?
● Unary operators.
● Binary operators.
● Ternary operators.

83. What is the realloc ()?


Realloc () is a dynamic memory management function, which is used to change the size
memory which is already initialized.

84. What is the initial value of local variables?

The initial value of local variable is garbage value.

[Amar-S2]

85. What is the initial value of global variables?


Zero (0);

86. What is the initial value of static global variables?


Zero (0);

87. What is the initial value of static local’s variables?


Zero (0);

[ajay-s2]

88. What is the difference b/w a structure and a union.


The difference between structure and union are:

● union allocates the memory equal to the maximum memory required by the
member of the union but structure allocates the memory equal to the total
memory required by the members.
● In union, memory is shared by all the members of union but in case of structure
each member have their own memory space.

[Sneha – S2]
89. What is structure padding (alignment)?
Size of the structure is compiler dependent because in some implementations extra bytes are
added in the structure, these extra bytes are called as padding. So that memory is aligned and
every object appears at even address location.

Padding are of two type:

● Internal padding: In this the padding is done between the elements of structures.
● External padding: In this padding is done at the end of structure.

For eg: if padding exists then assuming:

char variable are byte aligned and can appear at any byte boundary.

Short variables are 2 byte & can appear at multiple of 2 byte boundary.

Long variable are 4 byte so they should appear at the multiple of 4 byte boundary.

Struct example {

char c1;

short s1;

char c2;

long l1;

char c3;

}; external padding

Suppose starting memory location is 00.

00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
C1 Padd S1 S1 C2 Padd Padd Padd L1 L1 L1 L1 C3 Padd Padd Padd
ing ing ing ing ing ing ing

S1 (2bytes) internal padding L1 (4bytes)

[Sushmita Mazumdar-S2]

[Priyanka-S2]

90. What is the type returned by sizeof.


The type returned by sizeof() is unsigned int.

[Sneha- S2]

92.what is mean by endian? and What do you mean by little endian?


Endianness is the attribute of a system that indicates whether integers(multibyte datatype) are
represended from left to right or right to left.
The concept of endianness comes for multibyte. character is a singlebyte so the concept
of endianness dont go in to it ,and as integer is a multibyte so the concept goes well in to it.

Endianness comes in two varieties. Big and Little

In a little-endian system the least significant value in the sequence is stored first.(lowest storage
address)

[Rashmita-s2]

93.What do you mean by big endian?

In a big-endian system the most significant value in the sequence is stored at the lowest storage
address.

[Rashmita-s2]

94.How does a macro (with arguments) differ from functions?


A macro with an argument works like a function with argument,the
difference is macro replaces the defined text when called but function
executes the instructions and returns the result as return value to
the called function.In macros control transfer does not takes place
but in function control transfer takes place.

[Shuvashanmugam-S2]

95.What is break statement used for?


break statement is used to terminate the execution of loops and switch statement in
which it appears.
[Nilesh-S2]
96. What is continue statement used for ?

-The continue statement can be used to skip the rest of the body of an iterative loop. The use of a
continue statement violates the rules of structured programming, however, and a section
of code which uses a continue statement can always be rewritten to omit the continue.

- The continue statement can only be used within the body of a while, do, or for statement.

97.List the difference b/w for loop and while loop ?

-They are identicdal in terms of speed and memory consumption. You can always substitute a
while loop for a for loop, but not the other way around.For the syntax the two loops are
the same.

-The main difference comes into picture when you use continue with them i.e. for and while.
In a while loop if continue is used before the increment of a variable is done it converts
into a infinite loop.
i=1;
while(i<10)
{
/* do stuff */
if(i==6);
continue;
i++;
}
The above piece of code will turn into an infinite loop.
for(i=1;i<10;i++)
{
/* do stuff */
if(i==6);
continue;
}

In the above for loop the value of will be incremented once it attains the value 6.
Therefore it will not turn into a infinite loop.

98.What are the limitations of switch ?


-Logical operators cannot be used with switch statement. For instance
“ case k>=20: “ is not allowed .
Switch case variables can have only int and char data type. So float or no data type is allowed.

99.What is a stack frame . Explain what might get saved to stack frame ?
-A stack frame is a memory management strategy used to create and
destroy temporary (automatic) variables in some programming languages. Among
other things, use of a stack allows programming languages to allow recursive calling of
functions. Stack frames only exist at run-time

- Each stack frame contains space for actual parameters, local variables, temporary
locations, and (in some architectures) information about the calling context such as the
memory address of the calling function. When the called function finishes executing,
its stack frame is removed from the stack, and execution resumes back in the calling
function.

100.What are the advantages of recursion ?

101.Why is the use of goto statements discouraged in ‘C ’ ?


- The goto is a unconditional branching statement used to transfer control of the program from
one statement to another

-The goto statement is discouraged in C, because it alters the sequential flow of logic
that is the characteristic of C language. This word is redundant in C and encourages
poor programming style.

102.What is the difference b/w global and static global?


a. Ex: int g;
b. Ex: static int g;

- The global variable has a global scope and life time of the whole program. The
memory is allocated for each and every object.
-while a static variable has a local scope(can't be used outside the scope) but life time
of the whole program( its value persists even if the function returns). The memory is
allocated for static variables only once i.e all the objects shared by same memory

106. How do we write compound statements in c

A compound statement is any group of valid C statements enclosed in


braces.

Syntax for writing compound statement:

compound-statement :
{ declaration-list opt statement-list opt }

Where:

declaration-list :
declaration
declaration-list declaration
statement-list :
statement
statement-list statement

[Girish-S2]

111. What happens when a float values is assigned to an integer?


When float get assigned to integer, then internal truncation takes place and decimal part
will get stored in the integer variable.

For e.g :- int i;

float f= 1.10;

i= f;

printf(“%d”,i);

value of i is 1.

[Sushmita Mazumdar-S2]

112.What are the valid operations on structures?


● The only valid operations on structure variables as a whole are:

➢ Assign a structure variable to a structure variable of the same type


➢ Take the address of a structure (&)
➢ Use sizeof() to determine the size of a structure

[ Priyanka-S2 ]

113.How do we implement singleton structures?


A singleton structure is a design feature which allows only a single
instance of itself to be created to an anonymous structure (structure
without the name template).The programmer can access to that structure
only through the single instance created throughout the programm life
cycle and usually gives simple access to that instance.

Ex:
struct {
int i;
int b;
char c;

}s1; //s1 is the only instance of the structure struct.

[Nandini.s s2]

114. What is a sequence point?


A sequence point is a point in time at which all side effects are guaranteed to be
complete, since the result of some expressions depends on the order of evaluation of their sub-
expressions.

The sequence points listed in the C standard are:

● at the end of the evaluation of a full expression.


● at the ||, &&, ?:, and comma operators.
● at a function call.

[Sneha – s2]

115. What do you mean by a statement with side effects?

These are the statements which yields ambiguity in answers in different platform and there is
confusion in the evaluation of expression.
Eg: a[i]=i++;

[Sneha – s2]

117 .What is NULL and where is it been defined?


NULL is symbolic constant which is used in place of zero. IT is defined in <stdio.h>
[Priya-S2]
[Priya-S2]

119.What is dynamic memory allocation?


The process of allocating memory at the run time is known as
dynamic memory allocation.

[Shuvashanmugam-S2]

\ 120.What is the difference b/w a static local and a static global?


• Static global variable has scope only in the file in which it is
declared.
• Static local variable has scope in that function in which it is
declared. It can't be used in other functions in the same file also,
means scope is limited to the function in which it is declared.

[Nandini.s-S2]

121. Why the use of goto statement is discouraged in C?


Goto statements are unstructured programming style. In goto statements the control can jump to
another part of the program where the label is specified. The goto statement and the label should
be in same scope to compile the code successfully. As the number of goto statements increases
traceability and readability becomes difficult.

[Sushmita Mazumdar-S2]

122 . List the three standard files associated with a process?

Ans: 3 standard files associated with every process are :

Integer value Name

0 Standard Input (stdin)

1 Standard Output (stdout)


Standard Error (stderr)
2

[Priyanka-S2]

122 . List the three standard files associated with a process?


3 standard files associated with every process are :

Integer value Name

0 Standard Input (stdin)

1 Standard Output (stdout)

Standard Error (stderr)


2
[ Priyanka-S2 ]

123. How do you terminate from the program?


The "exit" function is used to terminate from the program and it returns the status value to the
system.

[Sneha – S2]

124. Summaries the differences in array declaration as per C89 and C99
std ?
In C89 std we declare the size of array at the time of decleration of array.
C99 adds a new array type called a variable length array type.
The *static *storage class specifier and any of the type-qualifiers, *
restrict*, *const *or *volatile*, can appear inside the *[ *and *] *that are
used to declare an array type, but only in the outermost array type
derivation of a function parameter.
[Vivek-S2]

127. What is the difference between global and static global?


Both Global and Static Global variable(object) remain for the entire
lifetime of the program.
However the difference is that the variable that is declared static
has scope only in the file in which it is declared where as the
variable declared without static can be accessed from other files
using an extern declaration.

[Girish-S2]

128. what is General Case & Base Case in Recursion(Recursive Algorithm)?

Ans. Each call of a recursive algorithm either solves one part of the problem or it reduces the
size of the problem.

The general part of the solution is the recursive call. At each recursive call, the size of the
problem is reduced.

The case when the function does not call itself recursively. This is called a base case.
We can also say that the statement that “solves” the problem is known as the base case.

Every function must have a base case; otherwise, the function will keep calling itself and will
never get around to returning a value.

The program will either crash or it will continue until an external effect stops it; it will certainly
not find the right value.

[Ankit Jain-S1]

What is Head, Tail & Middle Recursion?

Ans. If the recursive call occurs at the end of a method, it is called a tail recursion. The tail
recursion is similar to a loop. The method executes all the statements before jumping into the
next recursive call.

If the recursive call occurs at the beginning of a method, it is called a head recursion. The
method saves the state before jumping into the next recursive call. Compare these:

int tail(int n) int head(int n)

{ {

if(n == 1) if(n == 0)

return(1); return(1);

else else

printf("n=%d",n); head(n-1);

tail(n-1); printf("n=%d",n);

} }

Middle Recursion:The middle recursion has the recursive code in between other statements of
the function. In a function using middle recursion, there are statements, before as well as after
the recursive call.

int middle( int n)

if(n== 0)

return(1);

else
{

printf("n=%d",n);

middle(n-1);

printf("n=%d",n);

[Ankit Jain-S1]

You might also like