Search This Blog

Monday 17 January 2022

Practical No.7: To create a marks sheets of ten students.

GO TO INDEX

Computer Practicals For Class IX
Activity No.7


PRACTICAL NO. 7:
TO CREATE A MARKSHEET OF TEN STUDENTS


USE THE FOLLOWING STEPS
1. Marksheet Format in Excel:
That is why the management of schools uses MS Excel to maintain data of students. In the excel mark sheet, we have to manipulate the marks of students in various ways to evaluate their performance and give the result.

2. Start “MS Excel” program.

3. Fill your data by these information “SNO”, “Name”, “F/Name”, “English”, “Chemistry”, “Mathematics”, “Physics”, “Biology”, “Drawing”, “History”, “Total Marks”, “Marks Obtained”, “Minimum no”, “Maximum no”, “Average”, and “Grade”.

4. For example, if you type the formula =10/100 in cell A2, Excel will display the result as 0.1. If you then format that decimal as a percentage, the number will be displayed as 10%, as you 'd expect.

5. Type = 5 + 2 * 3 in another cell and press Enter or Return. Excel multiplies the last two numbers and adds the first number to the result.
Data 5
Formula Description Result
=A2+A3 Adds the values in cells A1 and A2 =A2+A3
=A2-A3 Subtracts the value in cell A2 from the value in A1 =A2-A3

6. So for each cell (in the Total column) we will enter =SUM(Grade Cell * Weight Cell), so my first formula is =SUM(B2*C2), the next one would be =SUM(B3*C3) and so on.

7. To insert a check mark symbol in Excel, simply press SHIFT + P and use the Wingdings 2 font. You can also insert a checkbox in Excel.

8. As an example, to add 10 to each cell, enter "10" (without the quotation marks here and throughout).
To increase the values by a certain percentage, add 100 to the percentage and enter the number with the percent sign, such as "150%" to add a 50 percent profit margin.

9. The percentage formula in Excel is = Numerator/Denominator (used without multiplication by 100). To convert the output to a percentage, either press “Ctrl + Shift + %” or click “%” on the Home tab's “number” group. Let us consider a simple example.


By Miss Shabana Sheikh And
By Sir Sajjad Akber Chandio



Practical No.6: To design a birthday card.

GO TO INDEX

Computer Practicals For Class IX
Activity No.6


PRACTICAL NO. 6:
TO DESIGN A BIRTH DAY CARD


USE THE FOLLOWING STEPS
Step 1: Make Up Your Mind on the Content of Your Card:
It is very important that before you start making your card, you should have in mind the type of things you would like to put down in the birthday card. You should sketch the details down on a piece of paper so as not to forget.

Step 2: Open the Microsoft Office 2010 on Your Computer:
After opening the Microsoft Word app in your computer, head to the file section > New > Blank document. After that, go to the page layout section and select orientation and then select landscape.

Step 3: Choose Number Of Columns:
Finally, go to the column section and select the number of columns you would like. Using two columns, you can now include images, any text you would like, and any type of decorations you would like to use on the column that is on the right side (hand) this is what will make up the front of your birthday card. The fact that you are using columns means that even if you fold it after printing it, the birthday card will be nicely lined up.

Step 4: You Ought to Change the Color of Your Background:
Click on the page layout section then click on the page color. The page color consists of many different types of colors that you can choose from. When choosing the right color, always consider the receiver's favorite color and not the color you prefer. You want the card to be perfect so as to make the receiver extremely happy. If you are not sure of the right color, then you necessarily do not have to put a background color. The background color will sometimes use up a lot of your ink, therefore it is not really a must.

Step 5: Add a Border:
At this step, you should go the page layout section and click on page border. Choose any style that is fun and appeals to you in the Art box and it consists of several patterns, different kinds of balloons, stars and even hearts. You should also choose the type of color.

Step 6: Add the Appropriate Text:
Head to Home and select Word Art section- here you can choose the type of text that you would like to use. You can decide on the text color or text size at this step.

Step 7: Add the Clip Art:
If you are using new version like Office 360, 2013 or 16 then unfortunately Microsoft Office no longer provide clip arts. But if you are using 2010 or earlier version then go to Insert and click on Clip Art.
Microsoft Word 2010 consists of many kinds of images you can pick and use. Click on the search section and type the word 'birthday'.

Step 8: Insert Your Own Pictures:
Go to insert and select pictures. You should have the pictures saved somewhere in a folder in your computer. Click on the folder which has the picture and select the one you are planning to use. You can decide to crop your picture or not. After you are satisfied, save the file.

Step 9: Edit Your Card:
You should go through your card just to make sure everything is in order.

Step 10: Print and Save Your Card:
Printing is done just like the way you print a normal power point file and the save it in your computer.


By Miss Shabana Sheikh And
By Sir Sajjad Akber Chandio



Practical No.5: Insert automatic table of content with two headings.

GO TO INDEX

Computer Practicals For Class IX
Activity No.5


PRACTICAL NO. 5:
INSERT AUTOMATIC TABLE CONTENT WITH TWO HEADING


USE THE FOLLOWING STEPS
How do I insert a heading 2 in a Table of Contents?
Image result for INSERT AUTOMATIC TABLE CONTENT WITH TWO HEADING
To create a subheading in your table of contents, create the subheading in your document. Highlight it and click Heading 2 at the top of your screen.
It will be added to your table of contents, nested underneath the appropriate chapter heading.

Click where you want to insert the table of contents – usually near the beginning of a document. Click References > Table of Contents and then choose an Automatic Table of Contents style from the list.

A table of contents in Word is based on the headings in your document.

Create the table of contents
1. Put your cursor where you want to add the table of contents.
2. Go to References > Table of Contents. and choose an automatic style.

Update Table of content
1. If you make changes to your document that affect the table of contents, update the table of contents by right-clicking the table of contents and choosing Update Field.
To update your table of contents manually, see Update a table of contents.
If you have missing entries.

Missing entries often happen because headings aren't formatted as headings.
1. For each heading that you want in the table of contents, select the heading text.
2. Go to Home > Styles, and then choose Heading 1.
3. Update your table of contents.
To update your table of contents manually, see Update a table of contents.


By Miss Shabana Sheikh And
By Sir Sajjad Akber Chandio



Practical No.4: To write a leave application to a teacher.

GO TO INDEX

Computer Practicals For Class IX
Activity No.4


PRACTICAL NO. 4:
TO WRITE LEAVE APPLICATION TO CLASS TEACHER


USE THE FOLLOWING STEPS
In the subject line of the email put the reason, (Leave of Absence Request, Request for Leave of Absence) followed by
  • Your full name.
  • Explain the leave of absence request.
  • Include a closing.
  • Include your name.

Respected Sir/ Madam, I am (your name), studying in your school in class (class and section). This letter is to inform you that I had to take a leave from my classes on (dates of leave) due to unexpected fever. I hereby request you to consider my absence as leave.

What to include in a leave application for office?
Salutation.
Purpose of the application (subject)
Reason for leave.
Number of leaves needed (particular dates)
Work plan during your absence.
Contact information.
Signature.

Subject: Sick leave application

Dear Mr./Mrs. {Teacher’s Name},

I am writing to notify you that I need sick leave from School because of a COVID19 viral infection to me. I caught the infection yesterday evening in marriage party and since then have been feeling very weak.

As per the doctor, I need to take medication for fifteen days (quarantine at home), along with proper rest for at least two week. The letter from the doctor is attached, confirming the need of time to recover from the illness.

Kindly allow me a two week-long leave, until the {date}. Should I require an extended period off, I will let you know as early as possible.

Please feel free to contact me at your convenience, should you have any questions or require clarification concerning the ongoing illness. Thank you for your quick attention to this matter.

Sincerely,
{Your Name}


By Miss Shabana Sheikh And
By Sir Sajjad Akber Chandio



Practical No.3: Installation of Avg antivirus software.

GO TO INDEX

Computer Practicals For Class IX
Activity No.3


PRACTICAL NO. 3:
INSTALLATION OF AVG ANTIVIRUS SOFTWARE


INSTRUCTIONS
  • Click the name of your product to download the installation file: AVG Antivirus.
  • Run the downloaded file to start the installation process.
  • Follow the instructions on your screen.
  • When prompted, enter your AVG license number.
  • Complete the installation and restart your computer.

1. Click the button below to download the AVG Antivirus setup file, and save it to a familiar location on your PC. Downloaded files are saved to your Downloads folder.

DOWNLOAD AVG ANTIVIRUS FOR WINDOWS
2. Right-click the downloaded setup file AVG antivirus setup.exe and select.

Run as administrator from the context menu.
3. If prompted for permission by the User Account Control dialog,
click Yes.
NOTE: If you are unable to authorize installation of AVG Antivirus, refer to the following article for advice:
Managing administrative accounts on your Windows PC

4. Click Install to proceed with default installation,
or
5. click Customize if you want to make changes to the default setup. Additionally, untick the box if you do not want to install AVG Secure Browser.

6. Wait while setup installs AVG Antivirus on your PC.

7. Click Continue.

8. Click the Continue with Antivirus.

9. Click Run first scan to run a comprehensive Smart Scan and immediately check your PC for viruses, malware, bad browser add-ons, and other issues.

AVG Antivirus is now installed, but some components may not fully function until you restart your PC.


By Miss Shabana Sheikh And
By Sir Sajjad Akber Chandio



Practical No.2: Installation of Ms office 2010.

GO TO INDEX

Computer Practicals For Class IX
Activity No.2


PRACTICAL NO. 2:
INSTALLATION OF MS OFFICE 2010

INSTALL OFFICE 2010
Insert the Office 2010 disc into the drive When prompted, enter the product key. Read and accept the Microsoft Software License terms, and then click Continue. Follow the prompts to complete the Install wizard, and after Office installs, click Close.

What is MS Office installation?
Image result for PRACTICAL to in short INSTALLATION OF MS OFFICE 2010. You how to download and install Microsoft Office on your Windows or computer. Microsoft Office is a suite of software that includes Microsoft Word, Excel, PowerPoint, and more.

Steps To Install Ms. Office 2010:
  1. Uninstall any old versions of Office:
    Keeping any older versions of Office installed can cause errors and problems with your files. To remove old installations. Open the Control Panel and select Programs and Features (Windows Vista, 7, 8), or add/Remove Programs (Windows XP). Wait for the list to load and then select your old Office installation. Click the Uninstall/Remove button and wait for the uninstallation process to finish before installing Office 2010.

  2. Insert your Office 2010 DVD:
    Alternatively, open the downloaded Setup file that you received when you purchased Office 2010 online. Either method will follow the same steps.

  3. Enter the Product Key:
    This is the 25-character key found on the packaging that your Office 2010 came in. If you purchased online, the key will be displayed in the order confirmation window.
    You do not need to enter the dashes in between groups of characters.

  4. Accept the License Terms:
    In order to proceed with the installation, you need to check the box indicating that you have read and agree to Microsoft’s terms of use.

  5. Choose your installation:
    Clicking Install Now will install all of the Office products included in the version that you purchased. Office will be installed to your default hard drive (the same that Windows is installed on).
    Choose Customize to specify which products you want to install. For example, if you never use Excel and just need Word, use Customize to disable the Excel installation. You can also use the Customize option to install Office to a different location on your computer.

  6. Wait for installation to complete:
    Once you have chosen your installation options, Office will be automatically installed. The amount of time this takes will vary depending on the version you are installing and the speed of your computer.
    Once Office is finished installing, you can access each of the individual Office programs from the Start menu.

By Miss Shabana Sheikh And
By Sir Sajjad Akber Chandio



Practical No. 1: Create or save new file or document. -

GO TO INDEX

Computer Practicals For Class IX
Activity No.1


PRACTICAL NO. 1:
CREATE AND SAVE NEW FILE OR DOCUMENT

Every Word project you create whether it’s a personal letter, a TV sitcom script, or a thesis in microbiology begins and ends the same way. You start by creating a document, and you end by saving your work.

  • Opening a Word document:
    Once you’ve created some Word documents, this method is fastest of all, since you don’t have to start Word as a separate step. Just open an existing Word document, and Word starts itself.
    Try going to Start → My Recent Documents, and then, from the list of files, choose a Word document. You can also double-click the document’s icon on the desktop or wherever it lives on your PC.

Creating a New Blank Document

Say you want a new blank document, just like the one Word shows you when you start the program. No problem here are the steps:
  1. Choose Office button → New.
    The New Document dialog box appears.
    To open the New Document window. Then click
    “New from existing”


  2. In the upper-left corner of the large
    “Create a new Word document”
    panel, click “Blank document”.


    The New Document box presents a seemingly endless number of options, but don’t panic. The “Blank document” option you want is on the left side of the first line.

  3. At the bottom of the New Document dialog box,
    Click Create.


    The dialog box disappears, and you’re gazing at the blank page of a new Word document.

Saving and Closing Documents

From the earliest days of personal computing, the watchword has been “save early, save often.” So, here are some tips to protect your work from disasters human made and natural.
  • Name and save your document shortly after you first create it. You’ll see the steps to do so later in this section.
  • Get in the habit of doing a quick save with the short key Ctrl+S, when you pause to think. Ctrl+S still works for a quick save too.
  • If you’re leaving your computer for an extended period of time, save and close your document.

Save Documents

Saving by keyboard shortcut:
  • Ctrl+S. If you’re an old hand at Word, this keyboard shortcut may already be burned in your brain. This command quickly saves the document and lets you get back to work.

Saving by menu command:
  • Office button → Save: If you don’t want to use keyboard shortcuts, you can mouse your way to the same place using menus. Like the options above, this command saves your file with its current name.

  • Office button → Save As: The Save As option lets you save your file with a new name. When you use this command, you create a new document with a new name that includes any changes you’ve made.

  • Office button → Close: When you close a document, Word checks to see if you’ve made any changes to the file. When you’ve made changes, Word always asks whether you’d like to save the document.


By Miss Shabana Sheikh And
By Sir Sajjad Akber Chandio

Thursday 13 January 2022

UNIT 05. FUNCTIONS - Text Book Exercise And Question Answers - Computer Science For Class X

GO TO INDEX

Computer Science For Class X
Unit 04: Control Structure
Question Answers

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


DETAILED NOTES

Q.No.1: Define functions and its categories or types.
Ans: FUNCTIONS:
A set of statements written to perform a specific task and having a unique name is called a function.

Sub-Programs:
In structured programming, the complicated and large program coding is broken down into smaller modules which are called subprograms. In C++, subprograms are called functions.
Every program has at least one main( ) function in C++. When the program starts, the main( ) function is called for execution.

CATEGORIES OR TYPES OF FUNCTIONS:
There are two categories or types of functions:
  1. Pre-defined Functions
  2. User-defined Functions

1. Pre-define Functions:
  • The pre-define functions are the part of every high-level programming language.
  • These functions are already defined in the system libraries. Therefore Predefined functions are also known as System-defined or library functions.
  • It can be used for different purposes.
  • These functions do not need to be declared and defined.
  • Pre-define functions are declared in header file.
  • All predefined functions can be used simply by calling the function like sqrt(), strcpy(), touppero, pow() etc.
  • Many pre-define functions need proper header file by using #include pre-processor directive.
  • The definitions of many common functions are found in the cmath and cstdlib libraries.

2. User-defined-function:
  • Programmer can also write their own functions to perform specific task. They are called user-define-functions.
  • These functions need declaration and definition.
  • When user defined function is called from any part of of the program , it will execute the code defined inside the body of function.
  • multiply(), sum(), average() etc are examples of User-define functions.
  • User defined function is based on two parts:
    (i) Function declaration or prototype
    (ii) Function definition

(i) Function Declaration:
  • A function without its definition (code block) is known as function declaration or function prototype.
  • It is declared before the main ( ) function.
  • It tells the compiler about the function’s name, return data types, and arguments/parameter data types and it ends with statement terminator (;).



  • where
    int = return data type
    my fun = function name
    float a, float b, char c = parameters
    ; = statement terminators

  • Basic  Syntax:
    i) Return Data Type:

    It shows the data type of value returned by function.
    It may be int, float, double and char data type.
    If no value is returned by the function in that case keyword “void” is used.

    ii) Function Name:
    It specifies the name of function.
    It is recommended that meaningful and understandable names are given to the function.
    It should not be a reserved word.

    iii) Parameters:
    It define the list of data types of function parameters that are to be passed to the function. or Information can be passed as parameters.
    Parameters are separated by commas.
    Parameters are also known as arguments.
    If there is no parameter in function, programmer uses keyword "void".
    They act as variables inside the function.
    Variable names are optional in prototype parameters/ arguments.

    iv) Statement Terminator:
    In function declaration, statement terminator are used to end the statement.

(ii) Function Definition:
  • Function definition is function itself. It provides the actual body of the function.
  • A function must be defined before it is used anywhere in the program.
  • It has a function header and a body or code block.
  • Header has three parts:
  • a) return value data type
  • b) function name
  • c) list of arugments with data types in parenthesis.
  • Body of the function includes statements in braces.
  • Function definition may be defined before or after the main function.



Q.No.2: What is function call?
Ans: FUNCTION CALL:
Functions are written by the programmer to define specific tasks. To use the function code the function has to be called or invoked with its name. These functions are called function call.
  • When function is called for execution, control will transfer to the function definition and all statements of function definition will execute and after executing the statements the control will transfer back to the calling function (statement after function call).
  • If the function is without return value and has no arguments then it is called by its name. In this case the function braces will remain empty.
    Syntax: function_name ( );
    Example: add( );
  • If the function returns a value, then we can store return value to a variable in calling function.
    Example: x=add (y, z);

Q.No.3: What do you understand by function passing argument or parameters?
Ans: FUNCTION PASSING ARGUMENT OR PARAMETERS:
Passing information from calling function to the called function is known as passing argument or parameters. Or An argument or parameter is a part of data passed to the function.
By using passing argument, we can share information from one scope to another in C++ programming language.

ACTUAL PARAMETERS:
When function is called for execution, the actual values which act as parameters are also given with function call statement. Passing actual values to function as arguments with function call statement are known as actual parameters.
  • Actual parameters may be variables or constants.
  • They are placed in parenthesis after the function name.
  • These values are received in variables of the header of function definition.
  • These receiving variables are called the formal parameters of the function.
  • It acts as a local variable inside the function in which they are used.

Q.No.4: What is returning value from function?
Ans: RETURNING VALUE FROM FUNCTION:
  • With value-returning functions, the actions result in the return of a value, and that value can be used in an expression.
  • In C++, the return keyword allows a function to return a value.
  • When a function completes its execution, it can return a single value to calling function.
  • Return data type must be specified with the function header in the function definition as well as function declaration.
  • It is written before function name.
  • Syntax: int function name( );

Q.No.5: Differentiate between function definition and function call?
Ans: DIFFERENCE BETWEEN FUNCTION DEFINITION AND FUNCTION CALL:
S.NO. FUNCTION DEFINITION FUNCTION CALL
1. A function definition provides the actual body of the function. Or The function definition is function itself. Function call is to invoke the code of function by its name.
2. A function must be defined before it is used anywhere in the program. The calling function asks the called function to perform a task.
3. It has a function header and a body or code block. Body of the function includes statements in braces. If the function is without return value and has no arguments then it is called by its name . In this case the function braces will remain empty.
4. Function definition may appear before or after the main() function. When the task is done the called function reports back to the calling function.
5. Syntax:
 data_ type function_ name
 (parameters list)
 {
 statements;
 }

 Example:
 int sum(int p, int q)
 {int z;
z = p + q;
return z;
 }
 Syntax:
 variable _name = Function _ name
 (parameter list);





 Example:
 a= sum (x,y)

Q.No.6: What are the different ways of using the user define functions?
Ans: Different Ways To Use User Define function (Based On argument / parameters and Retuen type):
There are four different methods to use user-define functions in C++, based on passing parameters to the function and return values from the functions. They are as follows:
  1. No return value and No passing arguments/parameters.
    void function name(void);

  2. Return value but No passing arguments/parameters
    int/float/char function name(void);

  3. No return value but Passing arguments/parameters
    void function name(int, float, char);

  4. Return value and Passing arguments/parameters
    int/float/char function name (int, float, char);

Q.No.7: Differentiate between pre- defined and user- define functions.
Ans: Difference Between Pre-defined And User-Define Functions
S.NO. User-defined Functions Pre -define Functions
1. These functions are not predefined in the Compiler. These functions are predefined in the compiler of C language.
2. These function are created by user as per their own requirement. These functions are not created by user as their own.
3. User-defined functions are not stored in library file. Library Functions are stored in special library file.
4. Their declaration and definition are needed in program. No need for function definition as that is part of C++
5. Execution of the program begins from the user-define function. Execution of the program does not begin from the library function.
6. Example: sum(), fact(),…etc. Example: gets(), putchar(), getch(),…etc.


Q.No.8: Explain the types of variables used in structured programming.
Ans: Types Of Variable Used In Structured Programming:
In structured programming, generally two types of variables are used.
  1. Local Variables
  2. Global Variables

1. Local Variables:
They are declared inside any function. A local variable is only accessible within a specific part of a program.


2. Global Variable:
Global variables are declared outside of the main function. It is also known as external variables. It holds the value of variable during the entire execution of the program. The value of global variables can be shared with different functions.


Here,
  • ‘a’ is global variable and
  • ‘x’ and ‘b’ are local variables.
  • Receiving arguments are also local variable as 'c' variable in this program.

B. RESPOND THE FOLLOWING:


1. Differentiate between function definition and function declaration?
Ans: Difference Between Function Definition and Function Declaration
S.NO. FUNCTION DEFINITIONFUNCTION DECLARATION
1. Function definition is a function itself. It has a function header, a body and a code block. A function without its definition (code block) is known as function declaration or function prototype.
2. It may be defined before or after the function. It is declared before the main() function.
3. Header has three parts: return value data type, function name and list of arguments with data types in parenthesis. It tells the compiler about the function's name, return data types and arguments /parameters data types
4. No statement terminators ( ); is required. It ends with statement terminators ( );
5. Determines the value stored in variable, function or class. Specifies the name and type of variable, function, class, etc.
6. The function definition reserves some amount of memory Function declaration doesn’t involve memory allocation.
7. Statements cannot be defined again if once it is already defined. Re declaration can be easily possible.
8. Duration is determined. Visibility is specified.


2. What is the purpose of keyword void in function?
Ans: Purpose of "void":
In computer programming there are different uses of “void”. They are as follows:
  1. When void is used as a function return type, it indicates that the function does not return a value.
  2. When used in a function's parameter list, void indicates that the function takes no parameters.
  3. When void appears in a pointer declaration, it specifies that the pointer is universal.

Position of Void:
If that function will not return a value, such as when the purpose of a function is to display some outputs on the screen, then "void" is to be placed at the leftmost part of the function header.
When a return value is expected after the function execution, the data type of the return value is placed instead of "void".

3. Why do we use header file?
Ans: Purpose Or Use Of Header File:
When we want to use any function in our C++ program then first we need to import their definition from C++ library. For importing their declaration and definition we need to include header file in program by using #include. Header file include at the top of any C++ program. The primary purpose of a header file is to propagate declarations to code files. Header files allow us to put declarations in one location and then import them wherever we need them. This can save a lot of typing in multi-file programs.

4. Differentiate between passing argument and return the value from function.
Ans: Difference Between Passing Argument And Return The Value From Function:
S.NO. PASSING ARGUMENT RETURN VALUE OF FUNCTION
1. Passing information from calling function to the called function is known as argument passing. In C++, the return keyword allows a function to return a value.
2. By using argument passing, we can share information from one scope to another in C++ programming language. With value-returning functions, the actions result in the return of a value, and that value can be used in an expression.
3. When function is called for execution, the actual values which act as parameters are also given with function call statement. They are called actual parameters. When a function completes its execution, it can return a single value to calling function.
4. These values are received in variables of the header of function definition. Return data type must be specified with the function header in the function definition as well as function declaration.
5. They are placed in parenthesis after the function name. It is written before function name.


5. What is the difference between external variables and function local variables?
Ans: Difference Between External Variables And Function Local Variables
S.NO. Local Variables Global or External Variables
1. It is declared inside a function. It is declared outside the function.
2. If it is not initialized, a garbage value is stored. If it is not initialized zero is stored as default.
3. It is created when the function starts execution and lost when the functions terminate. It is created before the program’s global execution starts and lost when the program terminates.
4. Data sharing is not possible as data of the local variable can be accessed by only one function. Data sharing is possible as multiple functions can access the same global variable.
5. Parameters passing is required for local variables to access the value in other function. Parameters passing is not necessary for a global variable as it is visible throughout the program.
6. When the value of the local variable is modified in one function, the changes are not visible in another function. When the value of the global variable is modified in one function changes are visible in the rest of the program.
7. Local variables can be accessed with the help of statements, inside a function in which they are declared. We can access global variables by any statement in the program.
8. It is stored on the stack unless specified. It is stored on a fixed location decided by the compiler.


6: List the five standard built-In functions with examples.
Ans: The C++ Standard Library provides a rich collection of functions for performing common mathematical calculations, string manipulations, character manipulations, input/output, error checking and many other useful operations. This makes the programmer's job easier, because these functions provide many of the capabilities programmers need. The C++ Standard Library functions are provided as part of the C++ programming environment.

C++ Standard Library Explanation
<iostream> Contains function prototypes for the C++ standard input and standard output functions. This header file replaces header file <iostream.h>.
<iomanip> Contains function prototypes for stream manipulators that format streams of data. This header file replaces header file <iomanip.h>.
sin(x) Sine of an angle x (measured in radians)
cos(x) Cosine of an angle x (measured in radians)
isalpha(c) It returns True if C is an uppercase letter and False if c is lowercase.
isdigit(c) It returns True if c is a digit (0 through 9) otherwise False.


7. Write down the advantages of user define function in C++.
Ans: Advantages Of User Define Function In C++:
User defined functions in C programming has following advantages:
  1. Reduction in Program Size:
    Since any sequence of statements which are repeatedly used in a program can be combined together to form a user defined functions. And this functions can be called as many times as required. This avoids writing of same code again and again reducing program size.
  2. Reducing Complexity of Program:
    Complex program can be decomposed into small sub-programs or user defined functions.
  3. Easy to Debug and Maintain:
    During debugging it is very easy to locate and isolate faulty functions. It is also easy to maintain program that uses user defined functions.
  4. Readability of Program:
    Since while using user defined function, a complex problem is divided in to different sub-programs with clear objective and interface which makes easy to understand the logic behind the program.
  5. Code Reusability:
    Once user defined function is implemented it can be called or used as many times as required which reduces code repeatability and increases code reusability.

8. Get the output and highlight the errors from the following program.


Ans: Compilation Failed After Running Codes


After Correcting Error Compilation Result:
Hint:
  • (Line 11: Add using namespace std;)
  • (Line 23: Replace "void" by "int")

Source: Special Thanks To Sir Syed Arif Ali

UNIT 05. FUNCTIONS - MCQs - Computer Science For Class X

GO TO INDEX

Computer Science For Class X
Unit 05: Functions
Multiple Choice Questions And Fill In The Blanks

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


Multiple Choice Questions (MCQs)
A. ENCIRCLE THE CORRECT ANSWER:
1. The functions that are defined by the programmer are called:
a. Built-In function
b. User-defined-function ✓
c. Sub function
d. Function

2. A programmer creates a function for a particular task and the programmer wants to include that function in program. Which extension is required to save that function?
a. .obj
b. .h ✓
c. .cpp
d. .exe

3. In C++, int main( ) returns which data type value by default?
a. float
b. int ✓
c. char
d. double

4. The parameters specified is the function header are called:
a. formal parameters ✓
b. actual parameters
c. default parameters
d. command line parameters

5. The word “prototype” means:
a. Declaration ✓
b. Calling
c. Definition
d. Both a & b

6. The function prototype consists of:
a. Name of function
b. the parameters are passed to the function
c. The value return from function
d. All of these ✓

7. All variables declared in function definition are called:
a. Local variable ✓
b. Instance variable
c. Global variable
d. Static variable

8. Which are not the built-In function?
a. sqrt( )
b. time( ) ✓
c. exp( )
d. sin( )

9. A group of statements written to perform specific task is called _____.
a. Program
b. function ✓
c. statement
d. variable

10. Functions are divided into ____________ sections.
a. 4
b. 3 ✓
c. 2
d. 1

11. Functions in C++ helps the programmer to manage the ___________ of a large program.
a. code ✓
b. declaration
c. statement
d. variable

12. There are ___________ categories of function.
a. 4
b. 3
c. 2 ✓
d. 1

13. Function ______tells the compiler about the function name, return types and parameters types.
a. Declaration ✓
b. Calling
c. Definition
d. Both a & b

14. Function _________ is to invoke the code of function by name.
a. Declaration
b. Call ✓
c. Definition
d. Both a & b

15. In C++ , _____________ functions are already declared in header file.
a. user-defined
b. pre-defined ✓
c. statements
d. Both a & b

Fill In The Blanks:
1. A programmer can write his/her own function which is called User-defined function.
2. A set of statements written to perform a specific task and having a unique name is called a function.
3. In structured programming, the complicated and large program coding is broken down into smaller modules which are called subprograms.
4. In C++, subprograms are called functions.
5. Every program has at least one main( ) function in C++.
6. When the program starts, the main( ) function is called for execution.
7. The pre-define functions are the part of every high-level programming language.
8. Predefined functions are also known as System-defined or library functions.
9. Predefined functions do not need to be declared and defined.
10. Many pre-define functions need proper header file by using #include pre-processor directive.
12. The definitions of many common functions are found in the cmath and cstdlib libraries.
13. User-defined-functions need declaration and definition.
14. Multiply ( ), sum( ), average( ) may be the example of User-define functions.
15. All predefined functions can be used simply by calling the function like sqrt(), strcpy(), touppero, pow() etc.
16. A function without its definition (code block) is known as a function declaration or function prototype.
17. Function declaration or function prototype is declared before the main( ) function.
18. A function declaration ends with statement terminator (;).
19. Return Data Type shows the data type of value returned by function.
20. Return data type may be int, float, double and char data type.
21. If no value is returned by the function in that case keyword "void" is used.
22. Function Name specifies the name of function.
23. Parameters define the list of data types of function parameters that are to be passed to the function.
24. Parameters are separated by (syntax) commas.
25. Parameters are also known as arguments.
26. If there is no parameter in function, programmer uses keyword "void".
27. In function declaration, statement terminator must be used at the end.
28. Function definition has a function header and a body or code block.
29. Body of the function includes statements in braces.
30. Function definition may be defined before or after the main function.
31. Function's braces will be empty, if the function is without return value and no arguments then it is called by its name.
32. An argument is a part of data passed to the function.
33. Passing actual values to function as arguments with function call statement are known as actual parameters.
34. Actual parameters may be variables or constants.
35. The receiving variables of the header of function definition are called the formal parameters of the function.
36. Global variables are declared outside of the main function.
37. Global variable is also known as external variable.

Source: Special Thanks To Sir Syed Arif Ali