Documente Academic
Documente Profesional
Documente Cultură
IN
CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
ROM: It permanently stores its data, even when the computer is shut
off. ROM is called non-volatile memory because it never loses its
contents.
ROM holds instructions that the computer needs to operate.
Number Systems - Binary Decimal Conversion
14) What is the weight of the digit 6 in each of the following decimal
numbers?
(a) 1386 (b) 54,692 (c) 671,920
Ans: (a) 6 (b) 600 (c)
15) Express each of the following decimal numbers as a power of ten:
(a) 10
(b) 100
(c) 10,000 (d) 1,000,000
Ans: (c) 1104 + 0103 + 0102 + 0101 + 0100
16) Give the value of each digit in the following decimal numbers:
(a) 471
(b) 9356 (c) 125,000
Ans: (b) 9 9000 , 3 300 , 5 50, 6 - 6
17)
How high can you count with four decimal
digits? 9999
18) Convert the following binary numbers to decimal:
(a) 1110 (b) 1010
(c) 11100 (d) 10000 (e) 10101
Ans (e) 21
19) Convert the following binary numbers to decimal:
(a) 110011.11
(b) 101010.01
(c) 1000001.111
Ans: (c) For decimal 1 26 + 0 25 + ...+ 1 = 65 for fractional:
1 2-1 + 1 2-2 + 1 2-3. Thus 65.875
20)
What is the highest decimal number that can be represented by
each of the following numbers of binary digits (bits)?
(a) two (b) three
(c) four (d) five (e) six
3
ans: (b) 7(2 1)
21) How many bits are required to represent the following decimal numbers?
(a) 17 (b) 35 (c) 49 (d) 68 (e) 81 Ans: (c) 49 = 110001 so minimum 6 bits
are needed.
22) Generate the binary sequence for each decimal sequence:
(a) 0 through 7 (b) 8 through 15 (c) 16 through 31 Ans:
(b) 1000,1001,1010,1011,1100,1101,1110,1111
Decimal-to-Binary Conversion
23)
Convert each decimal number to binary(by using the sum-ofweights method):
4
(a) 10
1 (b) 17
0 (c) 24 (d) 48 (e) 61 Ans: (c) 24 = 16 + 8 = 12 + 12 + 02 +
02 + 02 so 24 = 110002
4
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
24)
Convert each decimal fraction to binary using repeated
multiplication by 2 method
(a) 0.98 (b) 0.347 (c) 0.9028
Ans: (b) 0.3472=0.694; 0.6942=1.388; .3882=0.776;
0.7762=1.552; 0.5522=1.104 and so on.
So, approximately, 0.347 = .01011
25)
Convert each decimal fraction into binary by using the sum-ofweights method:
(a) 0.32 (b) 0.246 (c) 0.0981
Binary Arithmetic
26) Add the binary numbers:
(a) 11 + 01 (b) 10 + 10 (c) 101 + 11 (d) 111 + 110 (e) 1001 + 101 (f) 1101
+ 1011
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
48
Result = 00110110
54
29
Hexadecimal Numbers
34) Convert each hexadecimal number to binary:
(a) 3816 (b) 5916 (c) A1416 (d) 5C816
Ans: (a) 11 1000 0001 0110 (d) 0101 1100 1000 0001 0110
35)
Convert each binary number to
hexadecimal: (a)1110 (b) 10
ans: (a) E (b) 2
36) Convert each octal number to decimal:
(a) 128 (b) 278 (c) 568 (d) 648 (e) 1038 Ans: (a) 10 (c) 46 (d) 52 (e) 67
37) Convert each octal number to binary:
(a) 138
(c) 1018 (d) 3218 (e) 5408
(b) 578
Ans: (a) 001 011 (b) 101 111 (c) 001000001 (e) 101 100 000
38) Convert each binary number to octal:
(a) 111
(b) 10
(c) 110111 (d) 101010
Ans: (a) 7 (b) 2 (c) 67 (d) 52
39) Convert each of the following decimal numbers to 8421 BCD:
(a) 10
(b) 13
(c) 156
(d) 21
Ans: (a) 0001 0000 (c) 0001 0101 0110 (e) 0010 0101
40) Convert each of the BCD numbers to decimal:
(a) 10000000
(b) 001000110111
Ans: (a) 80 (b) 237
6
(e) 25
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
41) Convert each pair of decimal numbers to BCD, and add as indicated:
(a) 28 + 23 (b) 65 + 58 (c) 113 + 101 (d) 295 +
157 Ans: (a) 28 in BCD = 0010 1000
23 in BCD = 0010 0011
Carry
0100 1011
0001 0110
0101 0001
> 9 So add 6
51 is the result.
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
that, when provided with a set of input values, produces an output and
then terminates. An algorithm must have no ambiguity. There
should not be any uncertainty about the next instruction execution.
It should terminate in a finite number of steps.
55) What is meant by computational complexity of an algorithm?
It is the execution time of the algorithm in terms of its input parameters.
56) Explain the advantages of an algorithm.
A good algorithm helps the programmer to design the program in an
easier manner.
57) Define the term pseudo-code.
Pseudocode is not the actual name but it models and may even look like
programming code. It is the generic way of describing an algorithm
without using any programming language related notations. Or, more
simply it is the outline of the program, written in a form that can be
easily converted into real programming statements.
58) Give the advantages and limitations of flowchart.
Advantages: it makes the logic clear and visual. It communicates the
interconnection of the logical system. The problem can be well analysed.
Useful for coding the problem. Testing and debugging is easily done.
Flowcharts are good programming documentation for future reference.
Disadvantages: it is complicated. It is costly and difficult to modify in
future and no updates are easy to do.
59) Give the advantages and limitations of pseudocode.
Advantages: it is language independent. It is easier to develop
program from pseudocode than from flowchart. It is very compact
than a flowchart.
60)
What are the three basic program control
structures? Sequence, selection and repetition.
12
9)
10
8
8
4
5
6
5
3
6
8
8
8
5
8
5
8
6
8
8
8
6
8
UNIT II
Introduction to C programming fundamentals structure of a C
program
1) Why is C language called middle-level language?
C combines the features of high-level language and functionality like
assembly language. It reduces the gap between high-level language and
low-level language, that is why it is known as middle level language.
2) What are the functions of an interpreter and a compiler?
An interpreter reads only one line of the source program at a time and
converts into object codes. In case of errors, the same may be indicated
instantly. The compiler reads the entire program and converts it to the object
code. It provides errors not of one line but errors of entire program.
3) Write the rules for writing a C program.
a) All statements should be written in lower case. Upper case letters
are used only for symbolic constants.
b) Blank spaces may be inserted between words. This improves
the readability of the statements. But it is not used while
11
signed int
short unsigned int
Constants, Identifiers, variables and data types
10)
What is meant by a variable and a constant?
In a declaration, which consists of type, variable(one or more variables are
declared after the type, separated by commas) and delimited with a
semicolon. Moreover, during the type declaration, the variables so declared,
may be assigned with some corresponding values which has the following
format:
type variable = expression;
There are four basic types of constants in C. They are integer constants,
floating-point-constants, character-constants, and string-constants.
11) What are the C keywords? Elaborate them.
The following words are called reserved words or keywords and may not
be used by the user.
auto
double
int
struct
break
else
long
switch
case
enum
register
typedef
char
extern
return
union
const
float
short
unsigned
continue for
signed
void
default
goto
sizeof
volatile
do
if
static
while
13
12)
List the rules for declaring a
variable. <Data-type> <variable-name>
13)
What are identifiers?
An identifier is a sequence of letters or digits that is, a..z or A..Z or 1..9.
The underscore is an identifier. Identifiers have 31 characters which are
significant and some time more characters are considered to be
significant. Internal identifiers are preprocessor macro names. An external
identifier starting with an underscore is reserved for the C library.
1. First character must be alphabetic character or underscore.
2. Must consist only of alphabetic characters, digits, or underscores.
3. First 31 characters of an identifier are significant.
4. It can not duplicate a reserved word(as described before)
14)
Explain the methods for initialization of variables.
variable-name = constant;
Or
<data-type> <variable-name> [= <constant>];
15)
Write about space requirement for variables of different data types.
Data type
char
unsigned char
int
unsigned int
long
float
double
16)
Size(byte)
1
1
2
2
4
4
8
{} curly braces
Scope of statement
# hash
Pre-processor directive
, Comma
Variable separator
17)
List any three keywords with their use.
Operators and expression, Simple input and output functions
18)
What is the difference between %f and %g format specifiers? Can both
be used representing float numbers?
%f is decimal point format where as %g is a scientific format using exp
fields.
19) What do you mean by type conversion? Why is it necessary?
Implicit type conversion and Promotional hierarchy:
char short int unsigned int long int u
l int float double long double
So, when char and float are added, result will be a float. Similarly, if a
long is added with a double, the result will be a double according to the
promotional hierarchy, available.
Explicit type conversions
Cast. By having a unary operator called cast, we can convert the integer
to a float.
20) Explain different types of operators available in C.
Types of operator
Symbolic representation
Arithmetic operator
+, - , *, /, and %
Relational operator
>,<,==,>=,<=, and !=
Logical operator
&&, ||, and !
Increment and decrement
++ and -operators
Assignment operator
=
Bitwise operator
&, |, ^, >>,<<, and ~
Comma operator
,
Conditional oerator
?
21)
The (,) comma operator is used to separate two or more expressions. The
comma operator has the lowest priority among all other operator is C.
Conditional operator (?) The conditional operator contains a condition
followed by two statement values. If the condition is true the first
statement is executed, otherwise the second statement. The syntax is as
15
follows:
Condition ? (expression1):expression2);
22)
What are Unary operators and their uses?
+,-,++,--,!,~,*,&,sizeof and <type> are known to be
unary operators.
C includes a class for operators that act upon a single operand to produce a
new value. Such operators are called unary operators. Unary operators often
precede their single operands. The most common operation is unary minus,
where the numerical constant, variable or expression is preceded by a minus
sign. Note that the unary operator minus is distinctly different from the
arithmetic operator which denotes subtraction(-). The subtraction operator
obviously requires two separate operands.
23) Describe logical operators with their return values.
Operator
Meaning
&&
AND
||
OR
These are referred as logical AND and logical OR, respectively.
Suppose that i is an integer variable with value 3 and c is a character
variable with value 'w' and f is a floating point variable with value 3.56.
Several complex logical expressions that make use of these variables is
shown below.
Expression
Interpretation
Return
Value
(i <= 2) && (c > 34)
False
0
(c >= 56) | | (i == 4)
True
1
(c != 'x') && (f == 3.56)
true
1
The first expression is false because, the first operand is false. Where as in
the second expression, the second operand is false but the first operand
makes it effectively true. In the third expression, both the operands are
true.
24)
Logical operators return either true or false where as bitwise operator returns
the result of the operation.
25)
What are relational operators?
There are four relational operators in C. They are
16
Operator
Meaning
>=
greater than or equal to
> greater than
<=
less than or equal to
Meaning
= equal to
not equal to
are the ASCII codes? List the codes for digits 1 to 9, A to Z and a to z.
1-49(decimal) ...9-57(decimal ASCII), A-65(decimal ASCII)...Z-90, a97(decimal) and z 122(decimal ASCII).
32)
What are the formatted and unformatted I/O functions?
printf(),scanf() known as formatted I/O functions and
getchar(),putchar(),gets(),puts() functions are known to be
unformatted I/O functions.
33)
What is the difference between character I/O and string I/O?
Character I/O: Consider the function getchar(). This function reads the
character type data from the standard input. It reads one character at a time
and till the user presses the enter key. Similarly in putchar()function, it
prints one character on the screen at a time, which is read by the standard
input.
String I/O: Consider the function gets( ). This
function is used for accepting any string through stdin(keyboard) until
enter key is pressed. The header file stdio.h is needed for
implementing the above function. Similarly puts() prints the string or
the character array.
34)
What are the escape sequences?
An escape sequence like \n provides a general and extensible mechanism for
representing hard-to-type or invisible characters. Theyre summarised in the
table below
Escape sequence
Character
\a
alert(bell)
\b
backspace
\f
formfeed
\n
newline
\r
carriage return
\t
horizontal tab
\v
vertical tab
\\
backslash
\?
question mark
\'
single quote
\"
double quote
\ooo
octal number
\xhh
hexadecimal number
18
\0
null
0 1
1 0 1 2
Program
#include <stdio.h>
#include <conio.h>
main()
{
int a,b,c,d;
clrscr();
printf(%5d\n,0);
printf(%6d\n,101);
printf(%7d,21012);
getch();
}
Output
0
101
21012
38)
Every time when a case label matches, the corresponding case block
is executed. In the case-block a break statement is necessary to exit
the switch which is a limitation.
43)
loops? Yes
47)
What is the difference between (!0) and (!1)? How while loop works
with these values?
Actually !0 is 1 and !1 is a 0.
48)
8
8
4
6
8
5
6
16
8
8
8
16
and
its
value=%d\n,a,a[0]);
value=%d\n,a+1,a[1]);
value=%d\n,a+4,a[4]);
here, first printf will correspond to printing the base address of the array
under consideration and its value which is 1.
22
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
24
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
12)
size_t strlen(cs)
but it
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
exchange a[j]
with
a[j-1]
Line 3 in the above algorithm will execute n-1 number of times and in
the first loop and n-2 times in the second loop and so on. Thus, totally
the comparison(line 3) will occur
(n-1)+(n-2)+(n-3)+...+3+2+1 =
times.
18)
3) Explain the need for array variables. With respect to arrays, describe 8
the following: declaration of arrays, Two-dimensional array and
accessing an array element
4) Write a C program to find the largest and the smallest number in a
given array
5) Write a program that calculates the average of an array of 10
floating- 5 point values.
6) Write a C program to sort a given set of numbers in ascending order.
8
26
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
UNIT IV
Part A Questions and answers
Function definition of function Declaration of function, pass by
value, pass by reference
1) Write the definition of a function. Indicate the types of
functions available in C.
data-type name(type-1 arg-1, type-2 arg-2, , type-n arg-n)
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
Once a function is defined and called, it takes some data from the
calling function and returns a value to the called function.
The detail of inner working of function is unknown to the rest of
the program. Whenever a function is called, control passes to the
called function and the working of the calling function is stopped.
When the execution of the called function is completed, control
returns back to the calling function and executes the next
statement.
The values of the actual arguments passed by the calling function
are received by the formal arguments of the called function. The
number and type of the actual and formal arguments must be the
same. Any mismatch will produce unexpected result.
The function operates on formal arguments and sends back the
result to the calling function. The return() statement performs this
task.
5) List any five-library functions and illustrate them with suitable
examples.
float pow(float,float);
The above is the proto type for power function where the first
y
argument is raised to second power. That is x where x is first and
y is second argument.
z = pow(4.0,5.0);
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
This helps function in sending back the results to the calling module.
8) What does it mean if there is no return statement in the function?
Functions without return statement is not wrong if the function
return a void type otherwise, an error message will be displayed by
the compiler.
9) What are void functions?
They return no value to the calling module.
10)
Why is it possible to use the same variable names for actual
and formal arguments?
In the called module however new local variables are created
every time a function is called(except the function has reference
parameters)
11)
What is main () function in C? Why is it necessary in
each program? This is what is first invoked by the compiler to
further proceed.
12)
Explain the different formats of return ( ) statements. How
many values does return statement return at each call?
The return statement can be used in the following ways:
1. return(expression); Here expression value is returned
to the calling function and if expression is omitted return simply
transfers control to the calling function. 2. There may be one or
two return statements in a function. They may be executed
according to the condition arising in a program.
13)
What is a global pointer? Illustrate with a suitable example.
Normally pointers addresses declared outside a function are referred
as global pointers with respect to the called functions. Consider:
main(){
int a=3,b=4;
swap(&a,&b); printf(a=
%d b=%d,a,b);
}
void
swap(int
*m,int
*n){ int temp;
temp =
*m; *m =
*n; *n =
temp;
}
29
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
In the above code snippet, the function swap has an argument which
is of type pointer to an integer, passed on to the function which is
global with respect to the function swap.
14)
Why is return statement not necessary when function is
called by reference?
The reference parameters are transparent to the calling module so
the changes made by the function will automatically become visible
to the calling module upon a successful return of the called
function.
15)
Distinguish between function prototype and function
definition(code)?
Function prototype is the function declaration where as the function
definition is the actual content of the function statements return
values etc..
16)
Does the function prototype match with the function
definition? Yes.
17)
Can we define a user-defined function with the same library
function name?
No; but if the header file is not included for the particular program,
the function name will not conflict so it is allowed only in such
occasion.
18)
List and explain the four scope of variables in brief.
Automatic variables(local variables), External variables,
Staticvariables
and Register variables
19)
What are automatic/local variables?
These are defined inside a function. A variable declared inside a function
without a storage class name, by default is an auto variable. The scope of
the variable is local to the block in which they are defined. These
variables are available only to the current block or program. Once the
execution of the function takes place and return turns off function, the
contents and the existence of the auto variables or local variables vanish.
20)
Distinguish between static and external variables?
Static variable
External variable
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
body.
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
25)
Other language have pointers but few uses them so freely, with
such abandon, as C does. And why not? It's C's clever use of
pointers that makes it the excellent systems language.
Explain the use of (*) indirection operator.
(*)s operand is the address of a value stored in memory, and it
returns the value stored in that address.
The example below shows that:
void main()
{
int alpha = 1;
printf("The value %d is stored at address%u.\n",alpha,&alpha);
printf("The value %d is stored at address
%u.\n",*(&alpha),&alpha);
the output is
The value 1 is stored at address
9364. The value 1 is stored at
address 9364. after execution.
The expression alpha - that is, the name alpha by itself - and the
expression *(&alpha) do exactly the same thing: both cause C to
return the value stored at the address associated with the name alpha.
The expression &alpha returns alpha's address, and *(&alpha)
returns the value stored at that address.
26)
Explain the effect of ++ and -- operator with pointer of all
data types. Consider the following program
#include
<stdio.h> void
main ()
{
float *ptr;
static float zilch[] =
{1.23,2.34,3.45,4.56,5.67,0.0}; ptr = zilch;
32
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
ptr++;
}
}
The output would be
The value stored at address 4144 is
1.230000 The value stored at address 4148
is 2.340000 The value stored at address
4152 is 3.450000 The value stored at
address 4156 is 4.560000 The value stored
at address 4160 is 5.670000
Note the intervals between the address now. They are each 4. Our
references computer addresses its memory byte by byte, and an int
takes up two bytes where as a float uses four. The same case applies
to
operator as well.
27)
Explain the relation between an array and
a pointer. Consider the declarion:
int prime[4]={2,3,5,7},*ap;
Here prime[0] refers to 2 prime[1] refers to 3 and so on. But simply,
prime will mean a pointer to the number 2 in the above declaration.
By having an assignment as
ap = prime;
will initialise the pointer variable ap to point to the first position of
the array we have just declared and initialised above. Also a
statement like
ap++;
will increment the value of the pointer variable ap to point to the
next position of the array that is prime[1]. This is the
relationship between array and a pointer.
28)
Which are the possible arithmetic operations with
pointers? int array[5]; /* Declares 5 contiguous
integers */ int *ptr = array; /* Arrays can be
33
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
used as pointers */
6
6
6
8
8
8
10
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
struct
tag{ Memb
er1;
Member 2;
...
Member m;
};
In this declaration struct is a required keyword; tag is the name that
identifies this type; member 1, member 2 ... member m are
individual member declarations.
2)How are structure elements stored in memory?
Consider the declaration shown next page:
struct student
{
char name[30];
int rollno;
float height;
};
35
name[30]
rollno
height
struct studnt1 student;
The above declaration creates variables studnt1 of structure type student
and it reserves a total of 36 bytes(30 for the name[30], 2 bytes for the
rollno which is an integer and 4 bytes for float height)
3)Explain nested structure.
We can take any data type for declaring structure members like int, float,
char, and so on. In the same way, we can also take object of one structure as
members in another structure. Thus, structure within structure can be used to
create complex data applications. See below struct date
{
int dd; int mm;
int yyyy;
};
struct employee
{
char name[30]; struct
dob date; struct doj
date;
};
struct cseemp employee;
The above example shows how structure within structure is declared and it
36
dob
dd
mm
yyyy
doj
dd
mm
yyyy
4)What are aggregate types?
The structure is a kind of aggregate data type in C which is nothing but a
derived data type.
5) Can a structure have a pointer to itself?
Consider the following declaration for a node in a binary tree. Let us say the
node has a value which is of type integer and as it is a binary tree a node may
have two pointers pointing to two other nodes. This can be represented as:
struct *node
{
int value;
struct node *child1,*child2;
}
6) How is the declaration struct type{...}; different from typedef struct {...};?
By using typedef we can create new data type. The statement typedef
is to be used while defining the new data type. The syntax is as given below:
typedef type dataname;
37
Here, type is the data type and dataname is the user-defined name for
that type.
typedef int hours;
Here, hours is another name for int and now we can use hours instead of int
in the declaration as given below:
typedef int hours;
hours hrs;
7)How to keep track of which field of a union is in use?
In C it is not possible to know what type is currently stored in union.
8)What are the differences between a symbolic constant and an enumeration
constant?
enumeration constant
symbolic constant
Enumerations are unique types that
A #define line defines a
have integral values; associated with
symbolic name or symbolic
each enumeration is a set of named
constant to be a particular string
constants. Enumerations behave like
of characters:
#define name replacement list
integers, but it is common for a
compiler to issue a warning when an
object of a particular enumeration is
Example:
#define MAX 100
assigned something other than one
of its constants, or an expression of
its type.
Example:
enum months {JAN=1, FEB,
MAR, APR, MAY, JUN, JUL, AUG,
SEP, OCT, NOV, DEC};
Now the value of MAY would be 5 but
if we say
enum months {JAN, FEB, MAR,
APR=100, MAY, JUN, JUL,
AUG, SEP, OCT, NOV, DEC};
the value of MAY would be 101 but the
value of JAN would be 0
9)What are the various stages a program undergoes before xecution?
38
CSEITQUESTIONS.BLOGSPOT.IN CSEITQUESTIONS.BLOGSPOT.IN
CSEITQUESTIONS.BLOGSPOT.IN
Compiler
Object Code(.obj File)
Translation
Relocatable executable
Code (.exe File)
Loader
Address binding and
execution
39
Loading
10)What is a macro? What are object like macros and function like macros?
Preprocessor directives such as # define are used at the beginning of the C
program to define constants or any macro substitution.
#define <identifier> <replacement token list>
// The above one is an object-like macro
#define <identifier>(<parameter list>) <replacement token list>