Você está na página 1de 3

Qno.1 Differentiate between compiler and interpreter.

Difference between Compiler and Interpreter:


Compiler Interpreter
1. A compiler is a translator which transforms 1. An interpreter is a program which imitates the
source language (high-level language) into object execution of programs written in a source
language (machine language). language.
2. It takes an entire program at a time to be 2. It takes a single line of code or instruction at a
translated. time to be translated.
3. It generates intermediate object code. 3. It does not produce any intermediate object
code.
4. The compilation is done before execution. 4. Compilation and execution take place
simultaneously.
5. It is comparatively faster. 5. It is slower.
6. Memory requirement is more due to the creation 6. It requires less memory as it does not create
of object code. intermediate object code.
7. It display all errors after compilation, all at the 7. It displays error of each line one by one.
same time.
8. Detecting errors is difficult. 8. Detecting errors is easier.
9. C, C++, C#, typescript uses compiler. 9. Java, PHP, Perl, Python uses an interpreter.

Qno.2 Differentiate between high level and low level language with examples.
Difference between high and low level language:
High level language Low level language
1. The high level language is in human readable 1. Low level language is machine readable form of
form of program. program.
2. High level language is easy to write as well as 2. Low level language are difficult to write and
easy to compile. compile.

3. High level language uses compilers and 3. Low level language are compact and require less
interpreters which requires large memory memory space.
space.
4. In high level language debugging (Finding and 4. In low level language debugging (Finding and
correcting errors) is easier. correcting errors) is difficult.
5. High level language coding and compiling is 5. Low level language coding and compiling is time
much easy and takes very less time to compile. consuming process.
6. Example: BASIC, FORTRAN, Java, C++ and 6. Example: Assembly language.
Pascal.
Qno.3 Differentiate between Variables and Constants in C++.
Difference between constant and variable:
Constant Variable
1. Constant can never change their value. 1. Variables can change their value.

2. Constant is the named memory location whose 2. Variable is the named memory location whose
value can't be changed or whose value is fixed value can be change during execution of
during the execution of the program. program.
3. Constants must be initialized at the time of their 3. Variables can be initialize after its declaration
deceleration.
4. Pie is a good example to declare as a constant. 4. a=5; where a is variable.

Qno.4 Describe about keywords and token in C++.


Token:
A token is a group of characters that logically belong together. It is the smallest element
of a C++ program that is meaningful to the compiler. The C++ parser recognizes these kinds of
tokens: identifiers, keywords, literals, operators, punctuators, and other separators. A stream of
these tokens makes up a translation unit.
Keywords:
Keyword is a predefined or reserved word in C++ library with a fixed meaning and used
to perform an internal operation. C++ Language supports more than 64 keywords. Some
keywords are: auto, double, int, break, else, long, switch, case, do, while, char, return const,
float, continue, for, signed, void, default, goto, sizeof , if.
Qno.5 Writes the rules for declaring a variable in C++.
Rules for declaring Variable:
1. Variable names in C++ can range from 1 to 31 characters.
2. All variable names must begin with a letter of the alphabet or an underscore (_). For
beginning programmers, it may be easier to begin all variable names with a letter of the
alphabet.
3. After the first initial letter, variable names can also contain letters and numbers. No
spaces or special characters, however, are allowed.
4. Uppercase characters are distinct from lowercase characters. Using all uppercase letters
is used primarily to identify constant variables.
5. You cannot use a C++ keyword (reserved word) as a variable name.

Example:
 Grade, GradeOnTest are variable names that are acceptable.
 Grade (Test), GradeTest#1 are variable names that are not acceptable.
Qno.6 Explain the difference between flowchart and pseudocode.

Difference between flowchart and pseudocode:


Flow chart Pseudocode
1. Flowchart is a graphical representation. 1. Pseudo-code is something written in a
language.
2. A flow chart is just explaining the steps between 2. Pseudocode is readable code.
entities.
3. It uses different symbols for representation. 3. It usually uses English language.

Qno.7 what are data types? Explain main data types in C++.
Data Types:
All variables use data-type during declaration to restrict the type of data to be
stored. Therefore, data types are used to tell the variables the type of data it can store.
Whenever a variable is defined in C++, the compiler allocates some memory for that
variable based on the data-type with which it is declared. Every data type requires
different amount of memory.
Main Data types:
Integer:
Keyword used for integer data types is int. Integers typically requires 4 bytes of memory
space and ranges from -2147483648 to 2147483647.
Character:
Character data type is used for storing characters. Keyword used for character data type
is char. Characters typically requires 1 byte of memory space and ranges from -128 to
127 or 0 to 255.
Boolean:
Boolean data type is used for storing Boolean or logical values. A Boolean variable can
store either true or false. Keyword used for Boolean data type is bool.
Floating Point:
Floating Point data type is used for storing single precision floating point values or
decimal values. Keyword used for floating point data type is float. Float variables
typically requires 4 byte of memory space.
Double Floating Point:
Double Floating Point data type is used for storing double precision floating point values
or decimal values. Keyword used for double floating point data type is double. Double
variables typically requires 8 byte of memory space.
Void:
Void means without any value. Void data type represents a valueless entity. Void data
type is used for those function which does not returns a value.

Você também pode gostar