Search This Blog

Saturday 6 November 2021

UNIT 02: BASICS OF PROGRAMMING IN C++ - Text Book Exercise Ans SLOs Question Answers - Computer Science For Class X

GO TO INDEX

Computer Science For Class X
Unit 02: Basics Of Programming In C++
Text Book Exercise Ans SLOs Question Answers

B. RESPOND THE FOLLOWING:

Q.1: What is 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: List five common high level languages used and describe their purposes.
Ans: HIGH LANGUAGES WITH THEIR PURPOSES:
S.NO. Languages Purpose
1. Python Artificial Intelligence & Machine Learning
2. JavaScript  Rich Interactive Web Development
3. Java Enterprise Application Development
4. C / C++ Operating Systems and System Tools
5. Golang Server-Side Programming
6. C# Application & Web Development

Q.3: Using the rules of naming variable, develop ten meaningful and valid variable names.
Ans: VARIABLE NAMES:
S.NO. Variable Names S.NO. Variable Names
1. num16. _auto
2. num_27. Sum
3. average8. length
4. discount_rate9. percentage
5. Obtained_marks10. height

Q.4: Write differences between machine and assembly languages.
Ans: DIFFERENCE BETWEEN MACHINE AND ASSEMBLY LANGUAGE:
Assembly language Machine language
 Assembly language is only understandable by human being. Machine language is only understandable by computers.
 Modifications and error fixing can be done in assembly language. Modifications and error fixing cannot be done in machine language.
 It is easy to memorize the assembly language because some alphabets and mnemonic are used. Machine language is very difficult to memorize due to the use of binary format (0s and 1s).
 Execution is slow as compared to machine language. Execution is fast in machine language because all data is already present in binary format.

Q.5: What are strings in C++?
Ans: STRINGS IN C++:
Variables that can store alphanumeric value that consist of multiple characters are called strings. In C++ strings are used by one-dimensional array of characters, which is terminated by a null character \0.

Q.6: What are the differences between declaring and initializing variables?
Ans: DECLARATION (CREATING) VARIABLES:
Variable declaration is a process in which we create storage space for variable in memory. A variable declaration consists of data type and name of the variable written as follow:
  • data_type variable_name;
  • Int sum;

INITIALIZATION:
Assign initial value to a variable is known as variable initialization. It can be initialized during declaration or separately. The equal sign is used to assign value written as follows:
  • data_type variable_name = value;
  • Int sum = 3;

Q.7: List any three advantages of using an IDE.
Ans: 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 checked for errors to improve code.
  • Libraries provide for functions in IDEs that are not included in the core part of the programming language.

Students Learning Outcomes (SLOs) - Question Answers
By Mrs. Ayesha Arif
Vice Principal
(Jauhar Progressive School)

Q.1: Define Computer program OR Explain the concept of Computer program and programming language.
Ans: COMPUTER PROGRAM:
The set of instructions given to the computer are known as a computer program or Software, and the process of feeding or storing these instructions in the computer is known as computer programming.

PROGRAMMER:
The person who knows how to write a computer program correctly is known as a programmer.

PROGRAMMING LANGUAGES:
Computer cannot understand English, Urdu or any other common language that humans use for interacting with each other. They have their own special languages, designed by computer programmers. Programmers write computer programs in these special languages called programming languages. Java, C, C++, C#, Python are some of the most commonly used programming languages.

Q.2: Define syntax in programming language and syntax error? Also Describe the importance of syntax in any programming language.
Ans: SYNTAX:
Each programming language has some codes and rules in to write an accurate program. This set of rules is known as syntax of the language.
Importance Of Syntax In Programming Language:
  • Syntax can be thought of as grammar of a programming language.
  • It enables the computer read a set of code.
  • Syntax is the set of characters and keywords that a computer is able to read, interpret and convert.
  • Syntax play an important role in the execution of programs in text-based programming languages.
  • Text-based computer languages are based on sequences of characters, while visual programming languages like Visual basic are based on the layout and connections between symbols (which may be textual or graphical).
  • Example:
    In C++, this syntax displays the message "Hello World" on the screen.
  • Different programming languages using different types of syntax.

Syntax Error:
While programming, if proper syntax or rules of the programming language are not followed, the program does not compiled. In this case, the compiler generates an error. This kind of errors is called syntax errors. it is very common to new programmers to make syntax-based mistakes.

Q.3a: Define programming language and explain their classification?  OR Classify different programming languages into High, middle and low-level languages on the basis of their characteristics.
Ans: Programming Language:
A set of rules that provides a way of telling a computer what operations to perform is called a Programming Language. A programming language is a type of software that enables a computer understand specific instructions given to complete a task.
There are the following types of programming languages based on the accessibility of hardware .
  1. Low-level language
  2. Middle level language
  3. High level language

1. Low Level Language:
Low-level language is a programming language that can directly access and communicate with the hardware. It is represented in 0 or 1 forms . There are two types of low level languages.

  • Machine –Level language:
    It is the first generation programming language .The lowest language in hierarchy is the machine language ,therefore it has direct access to hardware. It is also called binary language because it is is written in binary digits 0s and 1s, means every instruction in Machine language consists of a series of 0s and 1s (binary code) that a computer can understand and execute directly. It does not require translator.

  • Assembly Language:
    It is second generation programming language . It is above the machine language therefore it has lesser accessibility to hardware. It is easy to write and maintain by humans. In assembly language, the statements are written in symbolic codes (termed as mnemonics) that are easier for human to read and write as compared to machine language because they are in simple English Language.

2. Middle-Level Language:
They were special purpose middle-level languages that were developed in the past . They have now become obsolete and are not used anymore.

3. High Level Language:
High level languages are closer to human languages than low-level language and include statement like GOTO and PRINT which are regular words. They do not have direct access to hardware therefore they require a translator (compiler or interpreter). Unlike the assembly language, the program of high level languages do not have to be written for a particular computer, but it can be executed on any machine that has a compiler for that language. FORTRAN, COBOL, BASIC, PASCAL, ADA, C-Language ,JAVA are some high level language.

Q.3b: Write down advantages of high-level language?
Ans: ADVANTAGES OF HIGH-LEVEL LANGUAGE:
The high-level language is easy to read, write, and maintain as it is written in English like words.
The high-level language is portable as opposed to low-level languages; i.e., these languages are not dependent on the machine.

Q.4:Differentiate between high level and low level languages?
Ans: Difference Between High Level Language And Low Level Language
S.NO. High Level Language Low Level Language
1. It is programmer friendly language. It is a machine friendly language.
2. High level language is less memory efficient. Low level language is high memory efficient.
3. It is easy to understand. It is hard (tough) to understand.
4. It is simple to debug. It is complex to debug comparatively.
5. It is simple to maintain. It is complex to maintain comparatively.
6. It is portable. It is non-portable.
6. It can run on any platform. It is machine-dependent.
8. It needs compiler or interpreter for translation. It needs assembler for translation.
9. It is used widely for programming. It is not commonly used now-a-days in programming.

OR
Low-level language High-level language
 It is a machine-friendly language, i.e., the computer understands the machine language, which is represented in 0 or 1. It is a user-friendly language as this language is written in simple English words, which can be easily understood by humans.
 It requires the assembler to convert the assembly code into machine code. It requires the compiler or interpreter to convert the high-level language instructions into machine code.
 One type of machine code cannot run on all machines, so it is not a portable language.  The high-level code can be translated to required machine-code, so it is a portable language.
 It has direct access to memory. It is less memory efficient.
 Coding and maintenance are not easy in a low-level language. Coding and maintenance are easier in a high-level language.

Q.5: Describe translators ,their role and types in detail?
Ans: TRANSLATOR:
Computers only understand machine code (binary) which is difficult to read, write and maintain. Therefore Programmers prefer to use a variety of high and low-level programming languages. Language translators are used to translate high level language into machine language so that computer can act upon the instruction given to it.
A program written in any language is called as source code.A translator takes a program written in source language as input and converts it into a machine language as output. It also detects and reports the error during translation.

Roles of translators:
1.Translating a program into an equivalent machine language program.
2. Providing alert messages wherever the programmer does not follow the rules of syntax of source language.

Different Types of Translators:
There are three different types of translators
  1. Compiler
  2. Interpreter
  3. Assembler

1. Compiler:
A compiler is complex system software that automatically converts a program written in some high-level language into an equivalent low-level machine language. The compiler or the language processor converts the entire program into machine code before execution. This translated program can be used again and again without the need for recompilation from source code.
It converts the whole program in one session and reports errors detected after the conversion. An error report is often produced after the full program has been translated. Errors in the program code may cause a computer to crash. These errors can only be fixed by changing the original source code and compiling the program again.

2. Interpreter:
An interpreter is another type of translator that converts each statement of a program written in a high level language into machine code and executes it before translating the next statement of the source program. It differs from a compiler that translates the entire source program into object program without undergoing its execution.
It translates the code line by line and reports the error as soon as it is encountered during the translation process. With interpreter, it is easier to detect errors in source code than in a compiler. An interpreter is faster than a compiler as it immediately executes the code upon reading the code.

3. Assembler:
An assembler is a translator used to translate assembly language to machine language. It is like a compiler for the assembly language but interactive like an interpreter. An assembler translates assembly language code to an even lower-level language, which is the machine code. The machine code can be directly understood by the CPU.

Q.6: Differentiate between Assembler, compiler and interpreter? OR Distinguish among various type of translators.
Ans: Difference Between ASSEMBLER, INTERPRETER And COMPILER
S.NO. ASSEMBLER INTERPRETER COMPILER
1. Assembler converts the assembly code into the machine code. Interpreter converts source code into the intermediate form and then converts that intermediate code into machine language. Compiler converts the source code written by the programmer to a machine level language.
2. Assembler inputs source code. Interpreter takes single instruction as input. Compiler inputs is preprocessed source code.
3. The output of assembler is binary code. In case of interpreter, No intermediate object code is generated. The output of compiler is a mnemonic version of machine code.
4. GAS, GNU Python, Perl, VB, PostScript, LISP etc. C, C#, Java, C++
5. Debugging is difficult. Interpreter is good for fast debugging. Debugging is easy.
6. Assembler converts source code to an object code first then it converts the object code to the machine language with the help of linker programs. Interpreter scans and translates the program line by line to equivalent machine code. Compiler scans the entire program first before translating into machine code.
7. Assembler is less intelligent than a compiler. Interpreter needs less memory when compared to compiler. Interpreter is slower when compared to compiler. Compiler is more intelligent than assembler.

Q.7: Describe errors and its types? OR Differentiate between syntax, runtime and logical errors.
Ans: ERRORS:
Errors are the mistakes made by the programmer during program writing. A program runs perfectly for the first time and each program needs to be tested to ensure that it is correct and contains no errors. There are three types of errors generally encountered.
  • a) Syntax Error
  • b) Logical Error
  • c) Run Time Error

a. SYNTAX ERROR:
The syntax of a programming language is the set of rules to be followed when writing a program in that language. These rules are similar to the grammar rules of Urdu or English language. When a program violates these rules, computer generates a syntax error. Syntax must be correct before program execution.
Most frequent syntax errors are:
  • Missing Parenthesis (})
  • Printing the value of variable without declaring it
  • Missing semicolon

b. LOGICAL ERROR:
These errors are the most difficult ones to find, if a programmer enters a sign of multiply instead of addition at the time of making the program, the answer will not be correct because interpreter will not be able the detect these types of errors. A logical error will not stop the execution of the program but the result will not be accurate.

c. RUN TIME ERROR:
These types of errors stop the execution of the program. It may be due to entering the invalid data at the time of executing a program. For example, if a program is expecting the user to enter the numeric data and the user enters a string data, computer will display an error message.

Q.8: Write a detailed note on programming environment of C++? OR Discuss about Integrated development Environment (IDE) of C++ & Develop the understanding about functions of different components of IDE.
Ans: PROGRAMMING ENVIRONMENT OF C++:
In order to correctly perform any task, we need to have proper tools. Therefore Programmer needs proper tools for programming. A collection of all the necessary tools for programming makes up a Programming environment. It is essential to setup a programming environment before we start writing programs. It works as a basic platform for us to write and execute programs. C++ runs on lots of platform like Windows, Linux, Unix, Mac, etc.

Integrated Development Environment (IDE):
The Software that provides a programming environment to facilitate programmers in writing and executing computer programs is known as an Integrated Development Environment (IDE). An IDE has a graphical user interface (GUI), meaning that a user can interact with it using windows and buttons to provide input and get output. An IDE consists of tools that help a programmer throughout the phases of writing, executing and testing a computer program. This is achieved by combining text editors, compilers and debuggers in a single interface.

Benefits of Integrated Development Environments:
  • Serves as a single environment for most of a developer’s needs such as compilation, linking, loading, and debugging tools.
  • Code completion capabilities improve programming workflow.
  • Automatically checks for errors to ensure top quality code.
  • Refactoring capabilities allow developers to make comprehensive and mistake-free renaming changes.

Components of IDE:
IDEs increase programmer productivity by combining common activities of writing software into a single application: editing source code, building executable, and debugging. Some IDEs for C programming language are:

  • Editing Source Code:
    Writing code is an important part of programming .Editing source code feature is a text editor designed for writing and editing the source code. Text editors enhance or simplify the writing and editing of code. IDEs facilitate this process with features like syntax highlighting and autocomplete.

  • Syntax Highlighting:
    Syntax highlighting makes code easier to read by visually clarifying different elements of language syntax.In this feature visual cues. Keywords, words that have special meaning are highlighted with different colors.

  • Code completion:
    Code completion features assist programmers by intelligently identifying and inserting common code components. These features save developers time writing code and reduce the chances of errors.

  • Compiler:
    Compilers translate programming language into machine language as binary code. IDEs provide automated build processes for languages, so the act of compiling and executing code is done automatically.

  • Linker:
    The linker opens the compiled program file and links it with the referenced library files as needed. Unless all linker items are resolved, the process stops and returns the user to the source code file within the text editor with an error message.

  • Loader:
    The IDE directs the operating system’s program called the loader to load the executable file into the computer’s memory and have the Central Processing Unit (CPU) start processing the instructions.

  • Debugging:
    Debugging is a step in which a programmer corrects a syntax error which may come after the compilation. When a program does not run correctly, IDEs provide debugging tools that allow programmers to examine different variables and inspect their code step by step.

Q.9: Define and differentiate between source program and object program?
Ans: SOURCE PROGRAM:
A program written by a programmer in a language other than machine language is called a Source Program.

OBJECT PROGRAM:
The output from a compiler or an assembler, which consists of machine language instructions, is called the Object Program.

DIFFERENCE BETWEEN SOURCE PROGRAM (CODE) AND OBJECT PROGRAM (CODE)
S.NO. SOURCE PROGRAM OBJECT PROGRAM
1. A collection of computer instructions written using a human readable programming language. A sequence of statements in binary digits that is generated after compiling the object program.
2. Contains English words according to syntax of programming language. Contains binaries.
3. Source code is another name for source program. Object code is another name for object program.
4. Programmers create the source program. Compilers create the object program.
5. It is the input to the computer. It is the output to the computer.
6. Programmers can read the source program Machines can read the object program.

Q.10: Write a short note on C++ programming and reserved words.
Ans: C++programming:
It is a general-purpose programming language that was created by Bjarne Stroustrup to make program writing easier and pleasant for programmers . It was an enhancement of the C language . It is a high-level language with an advantage of programming low- level (drivers, kernels) and even higher-level applications (games, GUI, desktop apps etc.). The basic syntax and code structure of both C and C++ are the same.

Reserved Words:
Every programming language has a list of words that are predefined. Each word has its specific meaning already known to the compiler. These words are known as reserved words or keywords. If a programmer gives them a definition of his own, it causes a syntax error. There is a total of 95 reserved words in C++. The reserved words of C++ may be conveniently placed into several groups. In the first group, we put those that were also present in the C programming language and have been carried over into C++. There are 32 of these.

Q.11: Describe the variables and constants in detail and Comprehend variable declaration rules in C++.
Ans: CONSTANTS:
Constants are those values that do not change while executing the program. Therefore the value is constant. Constants are used in two ways.
  1. Literal constant
  2. Defined constant

Literal constant:
It is a value typed into program wherever it is needed. Examples include the constants used for initializing a variable and constants used in lines of code:
21, 12.34, 'A', "Hello world! ", false, null

Defined constant:
There are some symbolic constants or named constants which are constants represented by name. The const keyword and #define preprocessor are used to define a constant. Many programming languages use ALL CAPS to define named constants like
const float PI = 3.14159; OR #define PI 3.14159.

VARIABLES:
Variables are the memory location that can hold a value. They are names used to represent values The values of a variable may be assigned by the programmer or it may be assigned as the result of calculation in the programme. Before a variable is assigned a value is assumed to be zero (or null for string variable).

Rules for Naming Variables:
  • The general rules for constructing names for variables are:
  • Names can contain letters, digits and underscores.
  • Names must begin with a letter or an underscore (_).
  • Names are case sensitive (myVar and myvar are different variables).
  • Names cannot contain whitespaces or special characters like !, #, %, etc.
  • Reserved words (like C++ keywords, such as int) cannot be used as names.
  • Names cannot be longer than 32 characters in C++ by default.

Declaring Variables:
In C++, there are different types of variables. A variable declaration tells the compiler where and how much storage is to be created for the variable. A variable declaration specifies a data type and name for that variable as follows:

  • Syntax:
    data_type variable_name;
    Where type is one of C++ data types (such as int), and variable_name is the name of the variable (such as x or myName).

Initializing variables:
Variables can be initialized (assigned an initial value) in their declaration. The initializer consists of an equal sign followed by a constant expression as follows:

  • Syntax:
    data_type variable_name = value;
    The equal sign is used to assign values to the variable.

Strings in C++
Variables that can store non-numeric values that are longer than one single character are known as strings.
The C++ language library provides support for strings through the standard string class. This is not a fundamental type, but it behaves in a similar way as fundamental types do in its most basic usage. Strings can be declared without an initial value and can be assigned values during execution.

Q.12: List any five high level languages and describe their purpose.
Ans: Common High Level Languages:
  1. Python
  2. Java
  3. C++
  4. C#:
  5. JavaScript:
  6. Pasacl
  7. COBOL
  8. FORTRAN
  9. BASIC

Python:
Python is used for Data Analytics, Machine Learning, AI Programming, and many other tasks
Uses in Popular Apps: Google, Spotify, Instagram

Java:
Java Language is Mostly used for Mobile Application Development
Some popular uses of Java are: Facebook, Messenger, Whatsapp

C / C++:
C is general purpose language that also works well with microcomputers. It is useful for developing operating systems, spreadsheets programs, database programs, Browsers. C++ is a version of C that incorporates object-oriented technologies. Some Popular uses are: Windows, Mozilla Firefox

C#:
C# (C-sharp) is Mostly used in Developing Games and Web Applications Some Popular Uses are: Temple Run, Pubg

JavaScript:
Used in Developing Websites Some Popular Uses are: Netflix, Facebook Web

Pascal:
A language that is widely used on microcomputers and easy to learn is Pascal, named after Blaise Pascal, a French mathematician. This language has become quite popular in computer science educational programs.

COBOL:
COBOL which stands for Common Business-Oriented Language is one of the most frequently used programming languages in business. Though harder to learn than BASIC its logic is easier to understand for a person who is not a trained programmer.

FORTRAN:
Short for Formula Translation, FORTRAN is a widely used scientific and mathematical language. It is very useful for processing complex formulas. That’s why many scientific and engineering programs have been written in this language.

BASIC:
BASIC, in full Beginner’s All-purpose Symbolic Instruction Code, computer programming language is One of the simplest high-level languages, with commands similar to English, it can be learned with relative ease even by schoolchildren and novice programmers. Its small size and simplicity made BASIC a popular language for early personal computers.

Q.13: What is the difference between declaration and initialization?
Ans: Difference Between Declaration And Initialization:
Declaration:
tells the compiler about the existence of an entity in the program and its location. When you declare a variable, you should also initialize it.

Initialization:

is the process of assigning a value to the Variable. Every programming language has its own method of initializing the variable. If the value is not assigned to the Variable, then the process is only called a Declaration.

Q.14: Differentiate between constant and variables?
Ans: Difference Between Constants and Variables
S.NO. Constant Variables
1. A constant does not change its value during program execution. A variable, on the other hand, changes its value depending on instructions.
2. Constants are usually written in numbers and may be define as identifiers. Variables are always written in letters or symbols.
3. Constants usually represent the known values in an equation, expression or in line of programming. Variables, on the other hand, represent the unknown values.
4. Constants are used in computer programming. Variables also have its uses in computer programming and applications.

Q.15: List out different reserved words commonly used in C++ program.
Ans: RESERVED WORDS:
The following list the keywords or reserved words of the C++ language:
 and new
 asm nullptr
 auto Operator
 bool Or
 break private
 case protected
 catch public
 char register
 class reinterpret_cast
 const requires
 const_cast return
 continue short
 default  signed
 delete sizeof
 do static
 double static_cast
 dynamic_cast struct
 else switch
 enum template
 explicit this
 export Throw
 extern true
 false try
 float typedef
 for typeid
 friend typename
 goto union
 if unsigned
 inline Using
 int virtual
 long void
 mutable volatile
 namespace wchar_t
 not while

Q.16: Use different data types in a C++ program.
Ans: C++ DATA TYPES:
The data types supported in C++ are:



Source: Special Thanks To Sir Syed Arif Ali



Friday 5 November 2021

UNIT 03. INPUT/OUTPUT HANDLING in C++ - MCQs - Computer Science For Class X

GO TO INDEX

Computer Science For Class X
Unit 03: Input / Output Hnadling In C++
Multiple Choice Questions And Fill In The Blanks

Multiple Choice Questions (MCQs)

By Mrs. Ayesha Arif
Vice Principal
(Jauhar Progressive School)


A. ENCIRCLE THE CORRECT ANSWER:
i) The C++ header file contains function prototype for the standard Input and Output functions.
a. <iomain.h>
b. <iostream> ✓
c. <fstream.h>
d. <cstdio.h>

ii) Which operator is used for input stream?
a. >
b. <<
c. >> ✓
d. <

iii) gets stands for
a. get stream
b. get string ✓
c. get str
d. get std

iv) getch() and getche() are included in header file.
a. <cstdio.h>
b. <conio.h> ✓
c. <stdlib.h>
d. <stdio.h>

v) Which operator is used for logical AND operation?
a. &
b. && ✓
c. ||
d. !

vi) Which of the following operator is correct to compare two values of variables?
a. =
b. <=
c. ==
d. both b and c ✓

vii) Which of the following needs pressing Enter Key from the keyboard?
a. getch( )
b. getche( )
c. getchar( ) ✓
d. gets( )

viii) != operator belong to which type of operator.
a. Relational ✓
b. Logical
c. Arithmetic
d. None of these

ix) Which operator add the first operand to the second operand and gives the result to first operand.
a. *=
b. += ✓
c. ++
d. +

x) cout « 12-6/2; What will be the result on screen?
a. 3
c. 6
c. 9 ✓
d.12


MORE MCQs


11) The C++ program consists of __________________ parts.
a. 3 ✓
b. 4
c. 7
d. 2

12) It is used to include header files like iostream, conio.h, etc.
a. gets ( )
b. compiler
c. main( )
d. #include ✓

13) It is the collection of identifiers.
a. gets ( )
b. namespace ✓
c. main( )
d. #include

14) The ________ function is compulsory element of the C++ program.
a. gets ( )
b. namespace
c. main( ) ✓
d. puts ( )

15) The comment statements are those statements that are ignored by the ________.
a. operators
b. Compiler ✓
c. identifiers
d. terminator

16) The ________ are not executable.
a. gets ( )
b. namespace
c. comment statements ✓
d. #include

17) ________ is a standard library file that contains definitions of Standard Input and Output functions.
a. return value
b. multi line comment
c. cout statement
d. I/O Stream ✓

18) cout is an ___________ object.
a. input
b. output ✓
c. comment
d. statement

18) ________ is used to display the output through output device like monitor.
a. cout ✓
b. return value
c. main( )
d. #include

20) __________ is a string function and it is included in <cstdio> header file.
a. gets ( )
b. puts ( ) ✓
c. main( )
d. getch ( )

21) cin works as an___________________ object in C++.
a. statement
b. output
c. comment
d. input ✓

22) Statement terminator (;) is used for statement _________ in C++ programming.
a. middle
b. beginning
c. ending ✓
d. writing

23) Escape Sequences is a ________ characters.
a. non - printable ✓
b. printable
c. specific
d. executable

24) Escape Sequences is used only with ___________ statement.
a. cout ✓
b. return value
c. main( )
d. #include

25) These are special symbols used for specific purposes.
a. compilers
b. Operators ✓
c. identifiers
d. terminators

26) Each escape sequence must start with___:
(a) & (and sign)
(b) / (forward slash)
(c) \ (back slash) ✓
(d) % (percentage sign)

27) The multi-line comment begins with the character set of ____:
(a) */
(b) /* ✓
(c) \*
(d) *\

28) <stdio.h> is ____ file.
(a) Document file
(b) Spreadsheet file
(c) Header file ✓
(d) Executable file

29) Every C++ program must have this function.
(a) cout( )
(b) main ( ) ✓
(c) cin( )
(d) None of these

30) In this statement "int main(void)" the second void is:
(a) Return type
(b) Argument ✓
(c) Function
(d) Variable

31) The # symbol is called ____ directives.
(a) Preprocessor ✓
(b) Multiprocessor
(c) Postprocessor
(d) None of these

32) All C++ statements must end with:
(a) comma (,)
(b) semicolon (;) ✓
(c) >
(d) <

33) This is a statement terminator in C++.
(a) ()
(b) "
(c) ; ✓
(d) :

34) Single line comment written in C++ with ___ symbol.
(a) /+
(b) // ✓
(c) *
(d) None of these

35) gets ( ) function is used to input data type:
(a) Character
(b) Integer
(c) Float
(d) None of them ✓

36) getche ( ) function gets a character and the character:
(a) Display ✓
(b) Print
(c) Read
(d) Variable

37) cin( ) statement is used to data from standard input device:
(a) Process
(b) Input ✓
(c) Output
(d) None of them

38) In which logical operator, the result of operation will be true, if both operands are true, otherwise false:
(a) NOT
(b) AND ✓
(c) OR
(d) None of them

39) Logical NOT operator takes operand:
(a) Two
(b) Three
(c) Four
(d) None of them ✓

40) The remainder operator (%) requires that both operands be:
(a) Float
(b) Integer ✓
(c) Double
(d) Character

41) Relational operators are used to two operands:
(a) Add
(b) Combine
(c) Compare ✓
(d) Collect

42) Increment and decrement operators operate on only one operand and are called:
(a) Unary operator ✓
(b) Binary operator
(c) Ternary operator
(d) None of these

43) \n escape sequence is used to move the cursor to:
(a) New page
(b) New line ✓
(c) New paragraph
(d) New section

44) Equality operator is denoted by:
(a) =
(b) == ✓
(c) !=
(d) None of them

45) The symbol >> is called:
(a) New line symbol
(b) Output operator
(c) Insertion operator ✓
(d) None of them

46) Which of the following operator works only with integer variables?
(a) Increment
(b) Decrement
(c) Binary operator
(d) Both increment & decrement ✓

47) If an increment or decrement operator is placed after a variable, it is called as:
(a) Pre-increment and Pre-decrement
(b) Post-increment
(c) Post-decrement
(d) Post-increment and Post-decrement ✓

48) Which of the following escape sequence represents carriage return?
(a) \r ✓
(b) \n
(c) \n\r
(d) \c

49) What value does the variable a have, after all of the code executes?
int a =1;
int b;
b = a++;

(a) 2 ✓
(b) 1
(c) 3
(d) Unknown / undefined

50) Those operators that require two operands are known as:
(a) Unary operators
(b) Binary operators ✓
(c) Ternary operators
(d) None of them

Fill In The Blanks:

1. The C++ program consists of three parts, Preprocessor Directives, main Function header and Body of program.
2. #include is used to include header files like iostream.h, conio.h, etc.
3. namespace is the collection of identifiers.
4. The main( ) function is compulsory element of the C++ program.
5. The comment statements are those statements that are ignored by the compiler.
6. The comment statements are not executable.
7. I/O Stream is a standard library file that contains definitions of Standard Input and Output functions.
8. cout is an output object.
9. cout is used to display the output through output device like monitor.
10. puts() is a string function and it is included in <cstdio> header file.
11. cin works as an input object in C++.
12. Statement terminator (;) is used for statement ending in C++ programming.
13. Escape Sequences is a non - printable characters.
14. Escape Sequences is used only with cout statement.
15. Operators are special symbols used for specific purposes.
16.Arithmetic Operator are used for arithmetic operations or calculation.
17. Increment and Decrement Operator are used in two different ways in programming, such as Prefix and Postfix.
18. Relational Operators are used to test the relation between two values.
19. Logical Operators are used to determine two relational expression.
20. Relational and Logical Operators works on a decision making and loops.


 



Biology For Class X - Chapter No. 4 - Support And Movement - Text Book Chapter

GO TO INDEX
CHAPTER 4: SUPPORT AND MOVEMENT

Text Book Chapter





















Biology For Class X - Chapter No. 4 - Support And Movement - Notes By FAW Group Of Education

GO TO INDEX
CHAPTER 4: SUPPORT AND MOVEMENT

Notes By FAW Group Of Education














For Educational News update like our FACEBOOK Page and YOUTUBE Channel:
 Face Book  : FAW Educational & Skills Institute
You  Tube : FAW Group of Education
 Whatapp : Sir Waseem Ahmed Qureshi: 03150226373 (Any Comment OR Question about Biology Notes Contact on Whatsapp)



UNIT 02. BASICS OF PROGRAMMING IN C++ - MCQs - Computer Science For Class X

GO TO INDEX

Computer Science For Class X
Unit 02: Basics Of Programming In C++
Multiple Choice Questions And Fill In The Blanks


Multiple Choice Questions (MCQs)
A. ENCIRCLE THE CORRECT ANSWER:
1. A computer program is a collection of:
a. Tasks
b. Instructions ✓
c. Computers
d. Programmers

2. High-level languages have syntax that is:
a. Easily readable by humans ✓
b. Easily readable by machines
c. Easily readable by both
d. None of the above

3. Low-level languages have syntax that is:
a. Easily readable by humans
b. Easily readable by machines ✓
c. Easily readable by both
d. None of the above

4. The primary characteristic of a compiler is to:
a. Translate codes line-by-line
b. Translate low-level code to machine language
c. Detect logical errors
d. Translate codes all at once ✓

5. The primary characteristic of an interpreter is to:
a. Translate codes line-by-line ✓
b. Translate low-level code to machine language
c. Detect logical errors
d. Translate codes all at once

6. An Integrated Development Environment facilitates a programmer to:
a. Edit source code
b. Complete and highlight syntaxes
c. Debug and compile codes
d. All of the above ✓

7. All errors, detected by users are typically:
a. Syntax Errors
b. Semantic Errors
c. Run- Time Errors
d. Logical Errors ✓

8. Allowed names for declaring a variable:
a. Can contain whitespaces
b. Can be one of the reserved words
c. Can contain letters, digits and underscores ✓
d. Can be the same as its data type

9. A bool data can store following type of value:
a. Numbers
b. Strings
c. Fractional numbers
d. True or false ✓

10. Which data type occupies the most space in memory?
a. Character
b. Integer
c. Floating point
d. Double floating point ✓

11. An identifier cannot consist more than characters:
(a) 30
(b) 31 ✓
(c) 32
(d) 35

12. Integer reserves ___ bytes in memory:
(a) 2
(b) 4 ✓
(c) 8
(d) 35

13. Float data type consists of the following:
(a) Numbers only
(b) Numbers and decimal point ✓
(c) Special characters
(d) Alphabets

14. Which of the following type of errors is detected by a language translator:
(a) Program design
(b) Logical errors
(c) Arithmetic errors
(d) Syntax errors ✓

15. A pictorial representation of program is called:
(a) A flowchart ✓
(b) An algorithm
(c) Pseudocode
(d) None of these

16. Software that translates assembly language into machine language is a/an:
(a) Binary translator
(b) Assembler ✓
(c) Compiler
(d) Link-loader

17. This type of error is detected by compiler:
(a) Runtime
(b) Logical
(c) Syntax ✓
(d) None of these

18. This is statement terminator in C:
(a) { }
(b) ; ✓
(c) "
(d) None of these

19. IDE stands for:
(a) International Development Environment ✓
(b) Integrated Development Environment
(c) Important Design Environment
(d) None of the above

20. Double/floating point reserves ____ bytes in memory:
(a) 4
(b) 6
(c) 8 ✓
(d) 10

21. A char data type contains any valid enclosed in a single quote:
(a) Alphabets only
(b) Symbols only
(c) ASCII characters ✓
(d) None of them

22. There are basic types of constant:
(a) 2 ✓
(b) 4
(c) 6
(d) 7

23. An integer constant must not have ___.
(a) Positive
(b) Negative
(c) Decimal Point ✓
(d) Numbers

24. ___ is a program that converts high-level language to machine language.
(a) Assembler
(b) Compiler ✓
(c) Debugger
(d) Linker

25. Which of the following is used to link all the parts of the program together for execution?
(a) Loader
(b) Linker ✓
(c) Memory
(d) Preprocessor

26. The output of an assembler is called:
(a) Data file
(b) Task file
(c) Object file ✓
(d) Program file

27. Users write the programs in which language?
(a) Low-level Language
(b) Middle-level Language
(c) Decimal-format
(d) High-level language ✓

28. A type of error that cannot be detected by a language translator is said to be:
(a) Syntax error
(b) Logical error ✓
(c) Inception error
(d) Conception error

29. Type of error generated by some undefined terms or wrong spelling term in a program is known as:
(a) Compile error
(b) Runtime error
(c) Conception error
(d) Syntax error ✓

30. A type of error that a language translator can detect is called:
(a) Compiler error
(b) Syntax error ✓
(c) Conception error
(d) Runtime error

31. Error in planing a program's logic would generate a ___.
(a) Inception error
(b) Conception error
(c) Syntax error
(d) Logic error ✓

32. Which is a valid identifier or variable name?
(a) diameter ✓
(b) void
(c) 55
(d) $12

33. A runtime error ___ program execution at the statement that cannot be executed.
(a) Halts ✓
(b) Resumes
(c) Starts
(d) None of the above

34. The constant are also called as ___:
(a) Const
(b) Preprocessor
(c) Literals ✓
(d) None of the above

35. The ___ are just like variables except that their values cannot be changed.
(a) Named constant
(b) Basic constant
(c) Number constant
(d) Symbolic constant ✓


Fill In The Blanks:
  1. A computer program is a list of instructions that tell a computer what to do.
  2. We refer to syntax in computer programming as the concept of giving specific word sets in specific orders to computers so that they do what we want them to do.
  3. Different programming languages can be classified into high, middle and low-level languages.
  4. High-level languages are easy to read for humans and contain English language like words.
  5. Middle-level languages have a human readable format along with direct control over the machine's resources.
  6. Low-level languages are easy for machines to read and hard for humans.
  7. Low-level programs mostly comprise of binary digits and memory operators.
  8. There are three types of translators namely, compilers, interpreters and assemblers.
  9. Compilers convert high-level languages into machine readable format.
  10. Interpreters also convert high-level programs into machine readable format.
  11. Interpreters convert instructions line-by-line.
  12. Assemblers convert low-level languages into machine readable format with added benefit of being interactive like an interpreter.
  13. Programming errors prevent the program from being compiled or executed.
  14. Syntax errors are words or symbols unrecognized by a particular programming language.
  15. Runtime errors only occur during program execution mostly due to an invalid input.
  16. Logical errors are considered when incorrect results are obtained based on provided input.
  17. Logical errors do not interrupt program execution.
  18. IDEs stand for Integrated Development Environments.
  19. Integrated Development Environments (IDEs) are programs that facilitate writing, compiling and executing codes.
  20. IDEs usually provide a single environment for programmers to write and executes codes efficiently.
  21. C++ is a general-purpose high-level programming language.
  22. Reserved words are part of programming language syntax and cannot be used as name of variable, function or label.
  23. A constant is a named identifier having a value that cannot be changed.
  24. A variable is a named identifier with a value that can be changed during normal execution of program.
  25. Different types of values can be stored in variables. These types are called data types such as int, string, bool, etc.
  26. A variable can be declared by giving it a name and type.
  27. A variable can also be initialized during declaration by assigning a value to it.
  28. In C++, a variable is defined and initialized as: "data type variable name= value;"
  29. C++ offers various data types for holding values in variables.



Thursday 4 November 2021

English (Compulsory) For Class IX - Unit 3 - Education And Careers - Text Book Exercise 3.4 - 3.6

GO TO INDEX

Chasing Dreams

Text Book Exercise

UNIT 3.4 WRITING

Informal Emails
Informal emails are written to family, friends and colleagues (people with whom we work). Emails are different from letters. They are usually brief and to the point. The language used in such emails is informal.

(1)
 To: fareed.khan @gmail.com
 CC: sohail.ali@yahoo.com
 Subject: sports day practice
 
 Assalam-o-Alaikum,

 Please let me know whether you will be going to school next Saturday for the Sports Day practice. If you are going, we can plan to go together. Otherwise, I'll have to ask my brother to go with me.

 lqbal.




(2)
 To: adi188@ukmail.com
 CC:
 Subject: maths homework
 
 Dear Adil,

  I am having some difficulty in solving some of the maths problems that our teacher gave us as holiday homework. I know you are very good at maths so 1 need your help. We can work at my place or yours, whatever is convenient for you. Please let me know the date and time so that I can plan my other things accordingly.

 Regards

 Kapoor




(3)
 To: kapoor_sunil@hotmail.com
 CC:
 Subject: maths homework
 
 Sunil,

 I would be happy to help you with your maths homework. But, I also need your help with my science project. You always have such brilliant ideas! So, what do you say, we meet at 4 o'clock on Saturday, at your place. Tell your mother that I am looking forward to having the lovely savouries she makes for us whenever we sit down to study.
See you on Saturday.

 Bye.

 Adil




(4)
 To: shahidaji@gmail.com; rozina.ladak@yahoo.com; sita_kumari@gmail.com; diana77@hotmail.com; msfauzia@hotmail.com; chandalalmal@gmail.com
 CC: saira_guddu @yahoo.com; mahnaz.munni@hotmail.com
 Subject: wedding invitation

 This is to inform all of you that Saira's brother is getting married on Sunday, October 15, 2017, at 1:00 pm. Since she is very busy, she has asked me to invite all of you to the wedding. We can all meet at my house by 12 noon and then go to Saira's house together. Please let me know if you are planning to come or not, so that we do not wait for someone who is not coming.

 I hope everyone can come. We will have great fun and Saira will be happy!

 Nadia



Exercise 1
Look at all the emails above and complete the following table in your notebook.


After you have completed, work with your partner. Read the above informal emails. Note the differences of conventions, vocabulary, style, and tone.
Discuss the following aspects:

  • Do all the emails begin in the same manner?
    Ans: No, Each email start with different salutation.

  • Do all of them end in the same manner?
    Ans: No, each email have different closing followed by sender signature.

  • How is the style of these emails different from a letter to a friend?
    Ans: All emails are written with informal or no salutation and closing and have subject line which tells the main content of an email whereas informal letters are written without any subject line and have proper salutation and closing.
    A single email can send to many recipient with a common content including attachments if needed, whereas a letter is written to an individual in an informal manner.

  • Is the language use and vocabulary same or different? How?
    Ans: Yes, The language and vocabulary is different in both email and letter. In an email, the content is short containing the main purpose regardless of any informal conversation, whereas in letter the content is lengthy and is written in a common conversation manner.

  • Did you notice what is written in the subject line?
    Ans: Yes, each email has subject line which describe the main purpose to written an email.

Exercise 2
Work individually and write an informal email to a friend/ class fellow asking/ requesting for something that you need. Follow the format given in the emails above.

 To: abcd@gmail.com
 CC:
 Subject: Need help
 
 Dear abcd,

 I am facing a problem and I need your help. Due to death of my grand father, my parents left for Islamabad last night and tomorrow is the last day for the submission of examination form. We have to submit admission form along with fees Rs. 500/-. I would be grateful to you, if you could lend me Rs.500/- , which i would returned you when my parents come back to home at my earliest.

 Waiting for reply

 Regards

 XYZ


(Note: You may ask for books or dress etc)

Exercise 3:
Read the following compare and contrast essay. Notice how the introductory, body and concluding paragraphs are written. Underline the words that show similarity and those that show the differences. Once you have done this, discuss with your partner how a compare and contrast essay is written.

Autumn versus Spring

There are four seasons in a year: spring, summer, autumn and winter. But when it comes to culture and practices, one often sees two seasons receiving more attention than the others. These two seasons are spring and autumn. In many parts of the world, the arrival of these two seasons is celebrated in various ways. However, there are obvious differences between the two seasons.
Spring is the time of the year when the weather is considered as absolutely perfect, because the air is still cool, yet, it is pleasantly cool, a coolness that allows one to enjoy the weather, without getting cramped due to the cold or exhausted due to the heat. The spring season is also associated with rebirth. This is the time of the year when winter comes to an end and activity begins in plant, animal and human life. One can see new leaves on plants and colourful buds on trees that slowly change to green. Animals that sleep or slow down their activities in winter, start becoming more active, searching for food and preparing for an active summer life. Humans also become more active, with some getting the land ready for growing crops, and others doing work that has to be done before the heat of summer drains their energy. Along with work, many people also find time to enjoy the lovely spring weather.
Autumn, on the other hand, gives the signal that summer is over. lt is the time of the year when preparation for the winter starts. The leaves of the plants start changing colours once again, but this time they change into different shades of yellow, brown and red, and begin to fall off. The trees, instead of getting fully covered, as in spring, start shedding leaves and, ultimately, become barren, with a few leaves or none left at all. The animals start hoarding their food in preparation for the winter. The people have to work faster to get home quicker, as the days get shorter and night falls very quickly. Those working in the fields get busy reaping their crops and selling or storing their crops. In some parts of the world, people gather around fires and have fun.
All in all, spring gives the signal that winter has ended, and autumn gives the signal that summer is over. With spring comes the message of a new beginning, with green plants and trees. With autumn come the falling green, red and brown leaves and barren trees. Spring is a call for action, and autumn announces more resting time, with longer winter nights about to come.


Ans: SIMILARITIES:
There are four seasons in a year: spring, summer, autumn and winter. But when it comes to culture and practices, one often sees two seasons receiving more attention than the others. These two seasons are spring and autumn. In many parts of the world, the arrival of these two seasons is celebrated in various ways. However, there are obvious differences between the two seasons.
SPRING
Spring is the time of the year when the weather is considered as absolutely perfect, because the air is still cool, yet, it is pleasantly cool, a coolness that allows one to enjoy the weather, without getting cramped due to the cold or exhausted due to the heat. The spring season is also associated with rebirth. This is the time of the year when winter comes to an end and activity begins in plant, animal and human life. One can see new leaves on plants and colourful buds on trees that slowly change to green. Animals that sleep or slow down their activities in winter, start becoming more active, searching for food and preparing for an active summer life. Humans also become more active, with some getting the land ready for growing crops, and others doing work that has to be done before the heat of summer drains their energy. Along with work, many people also find time to enjoy the lovely spring weather.

AUTUMN
Autumn, on the other hand, gives the signal that summer is over. lt is the time of the year when preparation for the winter starts. The leaves of the plants start changing colours once again, but this time they change into different shades of yellow, brown and red, and begin to fall off. The trees, instead of getting fully covered, as in spring, start shedding leaves and, ultimately, become barren, with a few leaves or none left at all. The animals start hoarding their food in preparation for the winter. The people have to work faster to get home quicker, as the days get shorter and night falls very quickly. Those working in the fields get busy reaping their crops and selling or storing their crops. In some parts of the world, people gather around fires and have fun.

DIFFERENCES:
  • Spring gives the signal that winter has ended, and autumn gives the signal that summer is over.
  • With spring comes the message of a new beginning, with green plants and trees. With autumn come the falling green, red and brown leaves and barren trees.
  • Spring is a call for action, and autumn announces more resting time, with longer winter nights about to come.

Exercise 4
Work with a partner and write a compare and contrast essay on any one of the following topics:

  • Summer and Winter
    CLICK HERE for above Essay

  • Pet and wild animals
    CLICK HERE for above Essay

  • City and village life
    CLICK HERE for above Essay

  • Good neighbours and bad neighbours
    CLICK HERE for above Essay




Email To Friend - Need Some Help

Go To Index

Informal Email
Work individually and write an informal email to a friend/ class fellow asking/ requesting for something that you need. Follow the format given in the emails above.

 To: abcd@gmail.com
 CC:
 Subject: Need help
 
 Dear abcd,

 I am facing a problem and I need your help. Due to death of my grand father, my parents left for Islamabad last night and tomorrow is the last day for the submission of examination form. We have to submit admission form along with fees Rs. 500/-. I would be grateful to you, if you could lend me Rs.500/-, which I would returned you when my parents come back to home at my earliest.

 Waiting for your reply!

 Regards

 XYZ


Email To Friend - For Wedding Invitation

Go To Index

Informal Email
Write an informal email to friends for wedding invitation.


(1)
 To: shahidaji@gmail.com; rozina.ladak@yahoo.com; sita_kumari@gmail.com; diana77@hotmail.com; msfauzia@hotmail.com; chandalalmal@gmail.com
 CC: saira_guddu @yahoo.com; mahnaz.munni@hotmail.com
 Subject: wedding invitation
 
 This is to inform all of you that Saira's brother is getting married on Sunday, October 15, 2017, at 1:00 pm. Since she is very busy, she has asked me to invite all of you to the wedding. We can all meet at my house by 12 noon and then go to Saira's house together. Please let me know if you are planning to come or not, so that we do not wait for someone who is not coming.

 I hope everyone can come. We will have great fun and Saira will be happy!

 Nadia



Email to a friend - For Maths Home work

Go To Index

Informal Email
Write an informal email to a friend / class fellow asking/ requesting his/ her help for maths home work.

(1)
 To: adil.xyz@gmail.com
 CC:
 Subject: maths homework

 Dear Adil,

  I am having some difficulty in solving some of the maths problems that our teacher gave us as holiday homework. I know you are very good at maths so 1 need your help. We can work at my place or yours, whatever is convenient for you. Please let me know the date and time so that I can plan my other things accordingly.

 Regards

 Junaid




(2)
 To: junaid.abcd@hotmail.com
 CC:
 Subject: Re: maths homework

 Junaid,

 I would be happy to help you with your maths homework. But, I also need your help with my science project. You always have such brilliant ideas! So, what do you say, we meet at 4 o'clock on Saturday, at your place. Tell your mother that I am looking forward to having the lovely savouries she makes for us whenever we sit down to study.
See you on Saturday.

 Bye.

  Adil



Email To Friend - For Sport Day Practice

Go To Index

Informal Email
Write an informal email to a friend / class fellow asking/ requesting for sports day practice.


(1)
 To: fareed.khan @gmail.com
 CC: sohail.ali@yahoo.com
 Subject: sports day practice

 Assalam-o-Alaikum,

 Please let me know whether you will be going to school next Saturday for the Sports Day practice. If you are going, we can plan to go together. Otherwise, I'll have to ask my brother to go with me.

 lqbal.