Friday, March 1, 2013

Ques-12:Define keyword or reserved word.What restriction apply to their use?

The definition of keyword or reserved word and restriction apply to their use is given below.

Solution:

Keyword or reserved word: In computer programming ,a keyword or reserved word is a word or identifier that has a particular meaning to the programming language.In C, there are certain reserved word, called keyword that have a standard pre-defined meaning.



Restriction to apply keyword: The keywords can be used only for their intended purpose.They cannot be used as programmer defined identifiers.The keywords are all lowercase.Since uppercase and lowercase character are not equivalent, it is possible to utilize an uppercase keyword as an identifier.Normally,this is not done , as it considered a poor programming practice.

Wednesday, February 27, 2013

Ques-11: Define identifier and describe the rules of identifier.

The definition of identifier and the rules of identifier is given below.

Solution:

Identifier: The names that are used to reference variables ,functions ,arrays ,labels and various other user-defined objects are called identifiers.


Rules of identifier:

1. An identifier name can vary from 1 to 32 characters.
2. The first character must be a letter or an underscore( _ ) with subsequent characters.
3. An identifier name cannot be the same as a C keyword and it should not have the same name as functions that are in the C library.
4. Must not contain white space.
5. In C,uppercase and lowercase are treated differently .Hence, count,Count and COUNT are three different identifier name.

Ques-10: What is variable? Where is it used?

The definition of variable and where it is used is given below.

Solution:

Variable: A variable is a named location in a memory that is used to hold a value that can be modified by the program.All variable must be declared before they can be used.

General form of variable declaration is -

                                                                      type_variable list;

Here type must be a valid C data type  and variable list may consist of one or more identifier names separated by comma (,).

         int i;
         double balance,profit,loss;


 Where it is used:

There are three basic places where variables are used.

1. Inside the funtion
2. In the definition of the function.
3. Outside of the function.

Ques-9: What is the difference between compile time error and Run time error?

The difference between compile time error  and Run time error is given below.

Solution:

Compile time error: Compile time error happens when the program is being compiled.Generally,compile time errors are syntax errors and they are caught by the compiler.An example of a compile time error might be leaving out a semi-colon in C.Compile time errors tend to be syntax errors.


Run time error: Run time errors  occur at run time .Generally,the program compiles but does not run correctly.An attempt to read past a null pointer in C would be an example of a run time error.Run time errors tend to be logic errors.

Ques-8: What do you mean by compile time and Run time?

The ques-8 solution is given below.

Solution:

Compile time: The time during which a program is being compiled.A common occurrence during  compile time is syntax error.

  Run time: The time during  which a program is executing.


Ques-7: What is the difference between compiler and interpreter?

The ques-7 solution is given below.

Solution:

Compiler:

1. Compiler translates a whole program from source code to object code if any wrong is not  found in the      code or program.
2. Compiler catches all wrong of a program together.
3. Lower execution time.
4. Requires higher program development effort and time.
5. It is more popular.
6. Compiler is used in PASCAL,C,C++  etc


Interpreter:

1. Interpreter translates and immediately executes each line of the program.
2. Interpreter catches the all wrong of a line together.
3. Higher execution time.
4. Requires less development effort and time.
5. It is less popular.
6. Interpreter is used in BASIC, DBASE,JAVA etc..

Tuesday, February 26, 2013

Ques-5: What is an Assembler? What is the difference between an Assembler and a Compiler?

The ques-5 solution is given below.

Answer:

Assembler: Assembler is a software or a tool that translates Assembly language into machine code.


The difference between an Assembler and a Compiler is given below.

Assembler:

1. Assembler is a computer program that reads code written in one language which is called Assembly language and translates into machine language.
2. Assembler is used in low-level Assembly language.
3. Assembler is less popular than compiler.


Compiler:

1. Compiler is a computer program that reads code (like C,C++ code )and translates into machine language.
2.  Compiler is used in high-level language.
3. Compiler is more popular than Assembler.

Ques-4: What is Assembly language? What is the problem of Assembly language?

The ques-4 solution is given below.

Answer:

Assembly language: Assembly language is a low-level programming language using the human readable instructions in the CPU.In PCs , the Assembly language looks like this,

  mov ebx,eax
  mov esi,66
  mov [edx+ebx*4+4],ecx
  mov [ebx],ah

To compile this code into machine code ,a compiler is needed.Assembler is the compiler for the Assembly language.


Problem of Assembly language: The problem with Assembly language is that it requires a high level of technical knowledge and it's slow to write.In the same time that you take to write ten lines of Assembly language- that's ten instructions,you could write ten lines of C++, perhaps the equivalent of 500 instructions.

Ques-3:What is machine language? How does machine language differ from high level language?

The ques-3 solution is given below.

Answer: 

Machine language:  Machine language is the name of the instructions that a CPU can execute.It is the translation of source code.Compilers generate machine language from source code.This language depends on 1 and 0.


The difference between machine language & high level language is given below.

Machine language:

1. Machine language is first generation language(1GL) .
2. It's bassed on 1 and 0.
3. There is no need of translation.
4. Not compatible with human language and human throught process.
5. Machine language is called the object program.


High-level language: 

1. High-level language is third generation language(3GL).
2. It's bassed on similar to english language( C, C++, BASIC, JAVA  etc ).
3. Must be translated into machine language before it can be executed.
4. More compatible with human language and human throught process.
5. High-level language is called the source program.