Sei sulla pagina 1di 6

1. What is a compiler?

Ans: A compiler is a computer program (or set of programs) that transforms


source code written in a programming language (the source language) into
another computer language (the target language, often having a binary form
nown as ob!ect code). "he most common reason for wanting to transform
source code is to create an e#ecutable program.
"he name $compiler$ is primarily used for programs that translate source code
from a high%level programming language to a lower level language (e.g.,
assembly language or machine code).
&. What is cross%compiler?
Ans: 'f the compiled program can run on a computer whose ()* or operating
system is di+erent from the one on which the compiler runs, the compiler is
nown as a cross%compiler.
,. What is compilation?
Ans: 'n computer programming, the translation of source code into ob!ect code
by a compiler.
-. .i+erences between native compiler and cross compiler.
Ans: A native or hosted compiler is one which output is intended to directly run
on the same type of computer and operating system that the compiler itself runs
on. "he output of a cross compiler is designed to run on a di+erent platform.
(ross compilers are often used when developing software for embedded systems
that are not intended to support a software development environment.
/.What is an interpreter?
Ans: 'n computer science, an interpreter normally means a computer program
that e#ecutes, i.e. performs, instructions written in a programming language. An
interpreter may be a program that either
e#ecutes the source code directly
translates source code into some e0cient intermediate representation (code)
and immediately e#ecutes this
e#plicitly e#ecutes stored precompiled code112 made by a compiler which is
part of the interpreter system
3. .i+erences between compiler and interpreter.
Ans: )rogrammers usually write programs in high level code, which the ()*
cannot e#ecute4 so this source code has to be converted into machine code. "his
conversion is done by a compiler or an interpreter. A compiler maes the
conversion !ust once, while an interpreter typically converts it every time a
program is e#ecuted (or in some languages lie early versions of 5A6'(, every
time a single instruction is e#ecuted).
7. What is a translator?
Ans: A "ranslator is a computer program that translates one programming
language instruction(s) into another programming language instruction(s)
without the loss of original meaning.
8. What is an assembler?
Ans: "ypically a modern assembler creates ob!ect code by translating assembly
instruction mnemonics into opcodes, and by resolving symbolic names for
memory locations and other entities.
9.What is a liner?
Ans: 'n computer science, a liner or lin editor is a program that taes one or
more ob!ects generated by a compiler and combines them into a single
e#ecutable program.
1:. What is a preprocessor?
Ans: 'n computer science, a preprocessor is a program that processes its input
data to produce output that is used as input to another program. "he output is
said to be a preprocessed form of the input data, which is often used by some
subse;uent programs lie compilers. )reprocessors are capable of performing
relatively simple te#tual substitutions and macro e#pansions.
11. Who calls main() in c program?
Ans: <ain function is called from ( startup assembly which is called by operating
system during creation of a new tas or process.
A tas or process starts from the entry point of the e#ecutable binary. )rograms
written in (=(>> languages are lined with a startup assembly routine and the
entry point is startup or start. "his startup routine has some responsibilities
before it can go to main function. 6tartup assembly does the following steps
before it !umps to main function.
6etup stac segment,
6etup data segment,
6etup 566 segment and clean 566,
setup tas related to platform,
)arse command line arguments,
!ump to main function
1&. 's main is a eyword?
Ans: main is not a eyword, it is an identi?er (it usually the name of a function in
c program).
1,. Where the de?nitions of printf(), scanf() presents?
Ans: printf(), scanf() are declared in header ?les but their de?nition is presented
in operating system. i.e at =lib=libc.so
1- . what is volatile in c?
"he volatile eyword acts as a data type ;uali?er.
"he volatile ;uali?er alters the default behaviour of the variable and does not
attempt to optimi@e the storage referenced by it.
1/. What is modi?er in c?
Ans: C Modifiers
To modify the properties of basic data types ,C programming language supports some
modifiers(generally they are keywords).
According to the properties of these modifiers, we can categorize the modifiers in
following groups:
Modifier Group Modifiers
1.Size modifier: short, long, nothing(not a keyword)
2.Sign modifier: signed, unsigned
3.Constant modifier: const, nonconst(not a keyword)
!.Storage Class: auto, register, static, e"tern
#.$olatile modifier: %olatile, non%olatile(not a keyword)
&.'ointer modifier: near, far, huge
(.)unction modifier: *ascal, cdecl
+.,nterru*t modifer: interru*t, noninterru*t(not a keyword)

Important Concepts:
nothing modifier must be default modifier of size modifier group.
!ointer modifier are not present in "#$%& gcc compiler.
#nterrupt modifier are mostly used in testing of a C program.
'torage Class modifier are (ery important in regards to )ynamic *emory
Allocation Concept in C programming language.
!ointer modifier,function modifier and interrupt modifiers are rarely used in
programming.
The list of default modifier in each group discussed
above:
Group Modifier
1. Size modifier nothing(not a keyword)
2. Sign modifier Signed
3. Constant modifier nonconst(not a keyword)
!. Storage Class auto or e"tern
#. $olatile modifier non%olatile(not a keyword)
&. 'ointer modifier near
(. )unction modifier cdecl
+. ,nterru*t modifer noninterru*t(not a keyword)

Very Important Terms:
#n storage class modifiers, the default modifier are auto and e+tern. There are two
cases for default modifier in storage class:
1. $aria-le declared locally (inside the functions) : auto
2. $aria-le declared glo-ally (outside the functions): e"tern

The default storage class modifier for C function is ,e+tern-.
The default size modifier is nothing(it is not a keyword) but we can specify it be using
a C keyword ,(oid-.
The default pointer modifier depends upon the memory model(T#$., '*A"",
*/)#%*, C0*!ACT, "A12/, 3%2/) of C language.
Important Concept:
)efault modifiers and default data types both are different,don4t be confused.
Compiler assumes int as the default data type for '#5/, '#2$, 'T01A2/ C"A'',
C0$'TA$T and 60"AT#"/ modifiers.
."am*les:
1. short "/101
,t has similar meaning to: short int "/101
2. signed "/101
,t has similar meaning to: signed int "/101
3. register "/101
,t has similar meaning to: register int "/101
Another Important Concept:
7e cannot declare such type of statements:
1.far 2*1
2.*ascal *s1
3.interru*t it*1
Rules to use C modifiers
Rule-1: To modifiers of the same group cannot be used to declare a
data type of C!
."am*le:
Short long int "1
signed unsigned int "1
e"tern auto char "1
long long int "1 etc.
Following declaration are valid:
const %olatile long "1
unsigned static long %olatile int "1

Rule-": #e can rite modifier either before the data type or after the
data type$ both are valid!
."am*le:
3nsigned float "1
4r
float unsigned "1
Rule %: The &rder of modifier'including data type (does not affect the
meaning of declaration!
."am*le:
int const long static "1
int static const long "1
long int static const "1
Rule ): *&I+T,R$ -.+CTI&+ and I+T,RR.*T modifier must be
ritten after the data type!
."am*le:
unsigned char far 2c1
char far unsigned 2c1
char far unsigned 2c1
far char unsigned 2c1
unsigned far char 2c1
First three declarations are valid as well as equivalent. But last
two declarations are invalid.
/ata types ith alloed modifiers
#n C, all modifiers cannot be used with each type of data type. 8ollowing is a list that
specify the names of data types with allowed modifiers.
Data Type Allowed Modifier
char: sign, constant, %olatile, storage5class
int: size, sign, constant, %olatile, storage5class
float: constant, %olatile, storage5class
dou-le: long, constant, %olatile, storage5class
%oid: no any modifier
enum: no any modifier
array: size, sign, constant, %olatile, storage5class
function: storage5class, *ointer, function
*ointer: size,sign, constant, %olatile, storage5class,*ointer
structure: constant, %olatile, storage5class
union: constant, %olatile, storage5class


13. what is type casting?
Ans: (asting represents a re;uest by the programmer to do an e#plicit type
conversion. 'n standard ( programming, casts are done via the () operator, with
the name of the type to cast to inside. Aor e#ample:
int nBalue1 C 1:4
int nBalue& C -4
Doat fBalue C (Doat)nBalue1 = nBalue&4
'n the above program, we use a Doat cast to tell the compiler to promote nBalue1
to a Doating point value. 5ecause nBalue1 is a Doating point value, nBalue& will
then be promoted to a Doating point value as well, and the division will be done
using Doating point division instead of integer divisionE
Why "he Array 'nde# 6hould 6tart Arom :?
Ans : 'n (, the name of an array is essentially a pointer, a reference to a memory
location, and so the e#pression array1n2 refers to a memory location n%elements
away from the starting element. "his means that the inde# is used as an o+set.
"he ?rst element of the array is e#actly contained in the memory location that
array refers (: elements away), so it should be denoted as array1:2. <ost
programming languages have been designed this way, so inde#ing from : is
pretty much inherent to the language.

Potrebbero piacerti anche