Computer Science 10th - Detailed Question Answers
Basics of Programming in C++
Q.1: Define Computer Program?
Ans. Computer Program:
A computer program is a set of instructions that performs a specific task when executed by a computer. A computer requires programs to function and typically executes the program's instructions in a central processing unit. A computer program is usually written by a computer programmer in a programming language.
Q.2: Define syntax OR What is syntax in programming?
Ans. Syntax in Programming Language:
Syntax refers to the rules that define the structure of a language. Syntax in computer programming means a set of keywords and characters that a computer can understand, interpret, and perform tasks associated with them. The syntax of a language must be defined, and if it is not followed, the code will not be understood by a compiler or interpreter. Different programming languages have different types of syntax.
Q.3: Describe classification of programming language.
Classification of Programming Language:
Based on the accessibility of hardware, programming languages can be classified into the following categories:
- Low-level language
- Middle-level language
- High-level language
Q.4: Define low level language.
Ans. Low-Level Language:
Low-level programming languages are those languages that are directly communicated with computer hardware. The two languages that come under this category are Machine language and Assembly language.
Q.5: Define machine language.
Ans. Machine-Level Language:
Machine language is a collection of binary digits or bits that the computer reads and interprets. This language is the only language understood by computers, while machine language is almost impossible for humans to use because it consists entirely of numbers (0s & 1s). Machine code doesn't require a translator because machine code is directly executed by the computer. It is also called a first-generation language.
Q.6: Define assembly language.
Ans. Assembly Language:
A program written in assembly language consists of a series of instructions called mnemonics that correspond to a stream of executable instructions. Assembly language code is translated by a translator called an assembler. Assembly language uses keywords and symbols much like English and is easier to read, write, and maintain compared to machine language. It is also called a second-generation programming language.
Q.7: Define middle-level language.
Ans. Middle-Level Language:
The middle-level language lies between the low-level and high-level languages. Middle-level language actually bridges the gap between machine-level language and high-level languages. These languages have now become obsolete and are no longer in use.
Q.8: What do you know about high-level language?
Ans. High-Level Language:
High-level languages are relatively new and have drastically revolutionized programming. They allow us to write computer code using instructions resembling everyday spoken language, usually English (for example: print, if, while). Programs written in a high-level language need to be translated by a translator (compiler or interpreter) into machine language before execution.
Q.9: Write down the advantages or benefits of high-level language.
Ans. Advantages of High-Level Language:
- High-level language is much closer to human language, making it more suitable to write code in high-level language.
- It is more or less independent or portable of the particular type of computer used.
- It is easier to read, write, and maintain.
Q.10: Write down the differences between low-level and high-level languages.
Ans. Differences Between Low-Level Language and High-Level Language:
Low Level Language | High Level Language |
---|
In low-level language, machine codes (0 and 1) are used as instructions to the computer. | In high-level language, English-like words are used as instructions to the computer. |
The execution of programs is quite fast. | The execution of programs is not very fast. |
Instructions are directly understood by the CPU. | Instructions are not directly understood by the CPU. |
No need to translate the program. In the case of assembly language, an assembler is required. | Translation of the program is required. |
The programs written in low-level languages are machine dependent and are difficult to modify. | The programs written in high-level languages are machine independent and are easy to modify. |
The examples of low-level languages are: (1) Machine language (2) Assembly language | The examples of high-level languages are: BASIC, FORTRAN, COBOL, PASCAL, C languages, etc. |
Q.11: Define translators or language translators.
Ans. Translators or Language Translators:
A language translator is a computer program that converts high-level language programs into low-level program (1s & 0s), or machine language. It transforms the source code into object code (machine code) which is directly understood by the computer processor. Translators also detect and report errors in the process of translation.
There are three types of language translators:
- Interpreter
- Compiler
- Assembler
Q.12: What is compiler?
Ans:
COMPILER
A compiler is a program that translates the high-level language program into machine language. Compiler translates the whole program at a time at once before it is executed and makes a separate object file for the translated program. The translated program can be used multiple times without the need of retranslating the source code. Each high-level language has its own compiler.
Q.13: Define Interpreter?
Ans:
INTERPRETER
An interpreter is a language translator program that converts high-level programs into machine language. It translates one instruction at a time. The interpreter does not make any object file, and it translates the program every time when executed. An interpreter is faster than a compiler as it immediately executes the codes.
Q.14: Define Assembler.
Ans:
ASSEMBLER
An assembler is a translator that converts assembly language program into machine language. An assembler translates assembly language code directly into machine code that can be understood by the CPU.
Q.15: Define source program or source code?
Ans:
SOURCE PROGRAM / SOURCE CODE
A program or a program written by a programmer in any language other than machine language is called a source program or source code.
Q.16: Define object program or object code.
Ans:
OBJECT PROGRAM / OBJECT CODE
Object program is a program or code that is converted into machine language. (OR) The output from a language translator, which consists of machine language instructions, is called the object program.
Q.17: Write down the differences between interpreter and compiler?
Ans:
DIFFERENCES BETWEEN INTERPRETER AND COMPILER
Interpreter | Compiler |
---|
Interpreter translates high-level language program into machine language line by line. | Compiler translates high-level language program into machine language as a whole. |
The interpreter translates the program every time when executed. | The compiler translates the program once at a time. |
Q.18: Define errors or programming errors.
Ans:
ERROR
An error describes any issue that arises unexpectedly that causes a program to not function properly. In general, there are three types of errors that occur in a computer program: Syntax Error, Logical Error, and Runtime Error.
Q.19: What is a syntax error?
Ans:
SYNTAX ERROR
A syntax error is an error in the syntax due to violation of rules of whatever language program is being written. These are commonly caused by simple typing mistakes.
Q.20: What is a logic error?
Ans:
LOGIC ERROR
In computer programming, a logic error is a bug or error in planning the program's logic. They do not cause the program to crash or simply not work at all, they cause it to "misbehave" in some way, rendering wrong output of some kind. The computer does not tell you what is wrong.
Q.21: What is a runtime error?
Ans:
RUNTIME ERROR
A runtime error is a program error that occurs when a program is run on the computer and the result is not achieved due to some misinterpretation of a particular instruction. The code doesn't have any syntax or logic error, but when it executes, it cannot perform the specific task.
Q.22: What is Programming Environment of C++?
Ans:
PROGRAMMING ENVIRONMENT OF C++
Programming environment is an environment which supports execution of programming language smoothly and efficiently on a local computer to compile and run programs.
Q.23: Define IDE or integrated development environment?
Ans:
INTEGRATED DEVELOPMENT ENVIRONMENT (IDE)
An integrated development environment (IDE) is software for building applications or programs that combines common developer tools into a single graphical user interface (GUI). IDE facilitates the development of applications designed to encompass all programming tasks in one application. One of the main benefits of an IDE is that they offer a central interface with all the tools a developer needs. Dev-C++ is used for writing programs in C++ language; however, there are many multiple language IDEs.
Q.24: Write down the benefits or advantages of Integrated development environment.
Ans:
BENEFITS / ADVANTAGES OF INTEGRATED DEVELOPMENT ENVIRONMENT (IDE)
- IDE combines all tools that need for development. Programmers don't need to switch between different tools to design a layout, write the code, debug, build, etc.
- Many IDEs incorporate basic spelling checkers, so automatically check for errors to improve code.
- Libraries provide for functions in IDEs that are not included in the core part of the programming language.
Q.25: What are the components of Integrated Development Environment?
Ans:
COMPONENTS OF INTEGRATED DEVELOPMENT ENVIRONMENT (IDE)
IDEs combine common tools that are necessary for a programmer to develop programs. These are:
EDITING SOURCE CODE
Writing and editing source codes is a major part of programming. A text editor is used for writing and editing source codes with features providing language-specific autocompletion, and checking for bugs as code is being written.
SYNTAX HIGHLIGHTING
Syntax highlighting is a feature of IDEs that provides visual cues. Keywords and other words that have special meaning in languages are highlighted. This feature makes code easier to read or understand.
CODE COMPLETION
It is a feature of IDE that completely knows the language syntax that speeds up the process of coding by reducing typos and other mistakes. Autocompletion popups while typing, querying parameters of functions, and query hints related to syntax errors.
COMPILER
Compiler is a component of IDEs that translates source code into machine code. IDEs provide an automated build process. This feature can help automate developer tasks that are more common to save time.
Q.26: Define Linker, Loader, and Debugging?
Ans:
LINKER
Linker connects or links referenced library files with compiled code. It saves the linked objects into an executable file.
LOADER
This is the operating system's program that loads executable files into memory and directs the CPU to start running the program as directed by the IDE.
DEBUGGING
The process of removing errors from a program is known as debugging.
Q.27: What do you know about Dev C++?
Ans:
INTRODUCTION TO DEV-C++
Dev-C++ is a fully featured graphical IDE (Integrated Development Environment) for programming in C/C++. Dev-C++ is developed by Bloodshed software. It was originally developed by Colin Laplace and first released in 1998. It is written in Delphi. With Dev-C++, a programmer can write Windows or console-based C/C++ programs easily.
Q.28: Write down the installation procedure of Dev C++.
Ans:
INSTALLING AND CONFIGURING DEV-C++ IDE
Dev-C++ is freely available for download on the Internet. After downloading the package, begin the installation process. The following are the steps for installing Dev-C++ IDE.
STEP 1:
Select "English" as the language to be used for the installation process.
STEP 2
Press "I Agree" button to agree to the license agreement.
STEP 3
Select "Full" from the dropdown menu for "type of install". Click on "Next" to proceed.
STEP 5
After completing the process, it will show a "Finish" dialog box. Click "Finish" button. This will automatically start Dev-C++ after installation completes.
CONFIGURING DEV-C++
Dev-C++ will require some configuration when it runs the first time. Set "English (Original)" as the default language and click "Next" to continue. On the "Theme" selection dialog box, leave the default setting and click on "Next" and "OK" to continue.
LINKER SETTING FOR DEBUGGING
Linker setting for debugging is required the first time to obtain information about problems in source code. The following steps are used to enable this configuration:
- Click on Tools, then Compiler Options, and open the Settings tab.
- Under the Settings tab, open the Linker tab. In the Linker tab, change the Generate Debugging Information (-g3) options to Yes.
- Click on OK to save settings
Q.29: Write down the procedure to develop a program in Dev C++.
Ans:
DEVELOPING PROGRAM IN DEV-C++
Development of C++ program requires writing source code and saving those files for compilation. The steps to create a new project in Dev-C++ are:
- Click on File, then click New » Project.
- In the New Project dialog, select Empty Project, then select C++ Project. Also enter Name for project.
- Click on OK. Dev C++ will ask for the path to save the new project, enter the path, and save the project.
ADD NEW FILES TO PROJECT IN DEV-C++
The steps to create a new file are:
- Click on Project » New File.
- Click on Yes on the confirm dialog box.
- To save the file, click on File » Save. Enter the path and provide its name. Click on Save to store the file.
COMPILE & EXECUTE PROJECT IN DEV-C++
The steps to compile and execute a project are:
- To compile, click on Execute » Compile or press F9 key.
- After successfully compiling the project, run it by clicking on Execute » Run or by pressing F10 key.
- A console will open and show the output of the program.
Q.30: What do you know about C++ programming language?
Ans:
C++ PROGRAMMING LANGUAGE
C++ is a powerful general-purpose programming language. It was created by Bjarne Stroustrup in 1979 at Bell Laboratories. It is used to develop operating systems, browsers, games, and other applications. C++ mainly supports object-oriented programming. C++ is a flexible language that aims to make writing programs easier and more pleasant for the individual programmer.
Q.31: Define reserved words in C++.
Ans:
RESERVED WORDS IN C++
Reserved words are keywords that have standard predefined meanings in the C++ language. These keywords can only be used for their intended purpose; they cannot be used as programmer-defined identifiers.
The following list includes the keywords or reserved words of the C++ language:
No comments:
Post a Comment