0% found this document useful (0 votes)
15 views

Procedures and Functions

o level cs

Uploaded by

edieali
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Procedures and Functions

o level cs

Uploaded by

edieali
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

Mental Strategy:

PNP:

• You have prepared enough and have stored all the things in your mind
• So you should behave naturally to talk
• it’s time to play live.

English-speaking strategy:
MS

• Mostly you will speak English except in extreme stuck condition be stylish bilingual
• Speak simple structures words. Don’t go for style.

How to handle when you don’t know the answer:


DO

1. Go deeper into the question to see if you can get more details that will help you figure it
out. You can tell the interviewer the steps you would take to figure out the problem.
2. If after going deeper the answer is something that is impossible to figure it out
independently. Here's what you can tell the interviewer:

"It's a good question, but right now, I don't have the answer off the top of my head.

About Cambridge:

No. of papers:
Current exams:
11 october paper 12

21 october paper 22

23 october paper 3 of 9618 a level cs

30 october paper 4 of 9618 a level cs

Threshold for CS June 2024:

Exam threshold for papers 12 and 22 of o level was 80% for garde a+ and 63% for grade a.

Gce or igcse?

Note that papers 1 and 2 have been done.


FAQs

CV related:

Tell me about yourself.


1. Well my name is Athar Ali. Currently, I am pursuing a successful career as a professional
teacher, mainly of the CIE Computer Science 2210 / 0478 courses for O Levels at the, delsol,
the school, PECHS branch, remember Delsol has almost 3-4 branches I teach at PECHS branch,
not tipu sultan rd or Gulshan branch. And also as adjunct lecturer of cs at duhs. Besides that
I teach at prime collegiate, Gulshan in the evening and doing private tutor FOR CAMBRIDGE
AND EDEXCEL BOARDS.. I also teach CIE computer science 9618 course for A Level as a private
tutor.
That’s what I am teaching currently but in past, [now refer to q2]
2. Rest of time, I do private tuitions and freelancing as a data analyst using python, excel and
other visualization software.
3. Overall, I have 15 years of teaching experience mainly 11 years as permanent faculty member
at Bahria College karsaz, where I taught computer science to the students of Cambridge,
Karachi and federal boards.
4. I am also item reviewer and subject panelist at AKEB.
5. And I have taught almost all levels from lower secondary to Masters.
6. As far as my education is concerned, I have done Masters in CS from department of CS, KU
and honors in Math and Stats from KU. And before that I also did CA foundation from Institute
of CA. So, my main subjects are Computer science, Math and Stats. And I can also teach
Economics, business studies and Accounting.
Currently, I am doing MS in CS with specialization in Artificial intelligence, which is a combined Commented [i1]: Artificial intelligence (AI) refers to the
field of Math, CS and statistics thus utilizing all areas of my education. simulation of human intelligence in machines that are
7. So teaching, education and research are my full time occupation. I am not a part-timer in this programmed to think like humans and mimic their actions.
The theory and development of computer systems able to
regard. perform tasks normally requiring human intelligence, such
8. Throughout my career, I have a number of accomplishments I would like to tell you about. as visual perception, speech recognition, decision-making,
Like, I won many times the best teacher awards at Bahria College and Ilma University. Many and translation between languages.
of my students have taken positions and A* grades in the board exams.
9. Furthermore, I can also consult and support you in the areas of any software making / using
of your institute and managing computer labs (HARDWARE).
10. I can also prepare students for different project competitions. Many times my students won 1st and 2nd
prizes in the science exhibitions, conducted by different boards.
11. I belong to an educated family. My father was a scholar of literature and philosophy, and my mother
was a teacher wife and all my siblings are also highly educated and well-employed. My wife is also a
master degree holder in the subject of Economics. I have two school-going lovely kids.
My hobbies include listening to music, reading motivational books and playing cricket.
12. Besides subject knowledge, I have also attended and completed a number of professional development
courses, video tutorials, seminars and webinars formally and informally, mainly at bckk’s bitt as these
things are of equal importance besides your subject knowledge that's why i have been very active in
acquiring and applying different techniques in my classroom.
Nowadays everything is available on internet. So I don’t wait for the formal registration for these types
of courses. Just download them and start learning them and start manipulating them in your classroom
and later on when I get some opportunity I will also complete it formally but nobody is restricting you
from learning and applying these things. So, currently, I am exploring from internet
1. Cambridge PDQs Module 1:

Currently I m learning bloom’s taxonomy:


ruaaec

In a nutshell of all these Cambridge course, there are five Cambridge teacher attributes. Cambridge
teachers are: CIRERR
o confident in teaching their subject and engaging each student in learning
o responsible and respectful of others
o reflective as learners themselves, developing their practice
o innovative and equipped for new and future challenges
o engaged intellectually, professionally and socially, ready to make a difference

Now see answer of q. 21-22.


• And I think these are the things essential for this position.
• Rest of things u can see in my CV.

Tell me your experience of teaching ‘A’ level CS:


Let me tell me where it began.

First of all O level CS:


I have been teaching ‘O’ level CS since 2009 as a private tutor, besides full time CS lecturer and HOD for
the college wing for Karachi and federal boards since 2006.

Later in 2011, when Karsaz started its Cambridge wing, I joined Cambridge wing of Karsaz College as
visiting teacher O level cs (7010) teacher for senior classes initially for grade 9 and later on the same
class becomes grade 10 and then grade 11.

I successfully taught 3 complete batches over there till 2017 (one of 7010 and two batches of 2210).

There were around 10 to 15 students in my class so overall I taught around 70 to 80 students there.
Most of students got As in computer. Around 20 to 25 got A+ and some got Bs. No student scored less
than B grade.

There is no A levels in karsaz branch.

1st vp of BCKz: uzma

2nd vp of bckz: samra

Now let me tell you about ‘A’ levels CS:


The story of A levels also began with private tuition in the year 2013 with the course code 9691 in that
period that become 9608 in 2015 and now it is has become 9618 in 2021.

In the year 2013, one of my colleagues told me that there was a need of A level CS teacher in NORE 1
branch because their full time teacher suddenly left the job. So I contacted them they called me for the
demo and got selected. So, after joing there, I left bahria college college wing for Karachi and federal
boards as I was already fed up with these boards and started as visiting lecture for both karsaz and nore
1.

In nore 1 I taught almost 4 years, 3 complete badges (means all 2 years) of a level cs till 2017.no of
students were around 30 and 17 of them got a grades, 5 got a+ and rest got b grades.

Principal Abrar amjad during 2014-19.

Delsol and Nexus


Then in the year 2017 they offered as full time but I refused because in evening I have joined ilma
university and it could be hectic for me and I joined two schools delsol and nexus as visiting faculty. At
nexus only o level and in delsol as both o level and a level. I taught a levels only one year at delsol. But
unfortunately delsol got split and they ended a level program and suddenly covid broke out and I was
feeling very insecure as visiting faculty member.

People at delsol:

Principal: sir shamsi

Coordinator:

Ms. Amna.

St. Michael’s:
In 2020, luckily got a full time opportunity at st. michael’s. At st michaels I mainly taught in o level
section except final year (9618) of batch 2021 in 2020. I taught paper 3 and paper 4 over there.

DUHS:
In 2022, I left st michaels due to multiple factors because full time besides ilma university and my
private tuitions became too hectic but I personally don’t like full time teaching but because of covid I
switched and now when things are normal I was looking for visiting opportunity. So I decided to quit it
when DUHS HR department found me though linked in and offered me visiting lecturership for their
different departments. They offered me same salary that I was getting at st. michaels. And there is much
job security here and also some research opportunities as well. So currently I m teaching there as
visiting faculty. And in evening I am teaching two online students of final year a level. Both are private
candidates and are in final year. Also teaching graduation courses at alhmad college and other private
tuitions. And now I have one morning slot available that I want to join somewhere as visiting faculty of
CS or IT.

LET me also tell you thayt I have associated with web and software development as well and have
developed many software and websites using different technologies but currently I have restricted
myself to data science and analysis.

People at st. michaels’:

Principal:

Peter Misquita

Vice principal

Seema nayyer

Section head of grade 9 to 11.

Ms. Mishal

A level councelor ms nousheen hammad

Senior supervisor:

Purnima naqvi

How many batches you have taught of AS level and what was the result?

What about Pearson’s Edexcel board?

Have taught International A level IT (XIT11 & YIT11). There are four units in this:
Unit 1: Hardware, software, networking and other theoretical topics

Unit 2: Web development

Unit 3: Spreadsheets, Data manipulation and system development lifecycle

Unit 4: mainly about DBMS along with emerging technologies like virtualization, project management,
augmented reality, etc.

i. How can you give us time?


Right now, conveniently, I can make myself available in 2nd half (i.e. 11 am till off time) 3 days /
week but it can be increased depending on your requirements.

ii. Why you didn’t join software development industry?


In the beginning of my career I had a plan to join software development after one to two years
of teaching. But later on I started to enjoy teaching and I was also appointed as the software in-
charge and HoD at bckk so things went on quite well in this way.

iii. Tell your Cambridge experience?


• I joined BCKz in 2006 as a college lecturer for both morning and afternoon shifts and switched
from college section to Cambridge wing in 2011 from the morning shift and kept teaching at
college section in the afternoon shift. I taught Computer science to O level and lower secondary
classes there. And for some sessions, I also taught mathematics there.
There, four of my batches appeared in Cambridge O level board exams in the years 2013, 2014,
2015 and 2016. In 2013, 12 students appeared then in 2014 year, 14 students appeared and in
2015 and 2016, 14 students appeared. Overall result was 100% for all years and almost none of
my students secured less than b grade except two who got c in 2013. [if someone ask about
specific grades then tell out of 50 students 26 students got A*, 14 got A and rest got b and 2 got
c].
Meanwhile, I kept continue to teach Cambridge students as private tutor and for some period of
time at Prime Collegiate (Gulshan block 2), in which mostly are from city school gulshan and
meritorious schools network and APC (COD). Mostly got As and Bs while five of them got A*. I
have also taught math, computer science AND Java to an A level student from lyceum at DHA, so
I can also deal Alevel students.
Then in oct, 2017, I joined ilma university as a full time lecturer (before that I was teaching there
as visiting lecturer since 2012) and left bckz. But later on, due to strict HEC policy of M.Phil, I
couldn’t continue full time lectureship over there and again I am doing visiting lectureship there
and have joined Al-Murtaza network as computer science teacher in morning. So in all of these
switching here and there, I learnt that Cambridge pathway is the most reliable and rewarding
way to teach. So finally I want to rejoin as full time faculty member in delsol school.
• At Delsol, I have taught last 3 years grades 9-11 as visiting faculty member and have almost 21
students appeared there. In 2019, 10 of my students appeared, in 2020, 7 students and in Last
year 4 students appeared and currently they have no student so I had to quit.
At delsol, students unfortunately weren’t very hard working and only 7 of them got A+. 5 As 8 got
B and 1 got C.

iv. Why did you leave the Bahria?


Because, I was a little bit fed up with military culture over there and Ilmauniversity offered
me permanent lectureship job and university has its own charm but unluckily, I couldn’t
continue there the permanent job because of MPhil requirement. That’s why I got enrolled
in MS (CS) program.
But up till now I have good relationship with them and you won’t believe that I am still
maintaining their official website, which I developed for them, free of cost.
v. Name some of people [like VPs and main teachers] @ Bahria.
1stvp: ms.Uzma
2ndvp: ms.samra
Mr hussain
Sir Nasimof Physics
Sir Habib of Math

vi. Presently teaching Cambridge?


Are you presently teaching somewhere Cambridge? Or when and what did you teach Cambridge
and which school students belonged to and what was the result?

Yes I am teaching at shfr gr 9-11..total 12 units in a week.

As, I told you, last year, I taught math, computer and Java to an A Level Lyceum student. But
after that I didn’t do any Cambridge tuition because of my teaching and research at university.

vii. Books and author names of your subjects?

viii. Have u taught ICT(0417)?


Yes but only in grade 8. Delsol follows ICT curriculum till grade 8. So that’s why I have knowledge
of this course, as well. But none of students took it in senior o level classes.

ix. Differences bw CS and ICT?


x. Whole year plan / Crash plan? Commented [F2]: 3. For the whole course plan and
Right now, only crash plan: Month-Wise Distribution of Topics see the file Dawood
Public School-course outline-Class 11.pdf.
What is your crash plan for your subjects for these 2.5 months?
O level Computer Science:

There are mainly three sections in this crash plan:


A. Instant Course Review:
Checklist:

B. Pre-Release Material
C. Solving Past papers
It includes:

i. Exams taking strategy.


ii. An Example Candidate response for the year 2015
iii. Solution of 2016-2019, keeping in view i and ii.

xi. Teaching techniques?


What is your general teaching methodology? Especially for weak students, junior and senior
students?

For such questions, read this:

https://www.themuse.com/advice/interview-questions-for-teachers-answers#question2

xii. How Do You Motivate Students?


• Encouragement
• Competitive environment
• Rewards like candies / chocolates / Student of the month / week
• Group discussions
xiii. How would you deal with students not listening to you?

xiv. How would you deal weak students?


Repetition, revising, having some extra sessions, inviting them on board. Change seating
arrangement to front side.

xv. How Do You Like to Communicate/Build Relationships With Parents?


Very important to understand family dynamics

xvi. What’s Your Teaching Style or Philosophy?


I would say I’m strict but fair when it comes to teaching.
xvii. Teaching Techniques

• Tell me,

I forget.

Show me,
I remember.
Involve me,
I understand.

• Variety in delivering the lectures


o Formal authority: Authoritative teachers incorporate the traditional lecture
format and share many of the same characteristics as experts, but with
less student interaction.
o Facilitator: Designs participatory learning activities and manages
classroom projects while providing information and offering feedback to
facilitate critical thinking.
o Delegator: Organizes group learning, observes students, provides
consultation, and promotes interaction between groups and among
individuals to achieve learning objectives.
o Flipped Classroom (Inverting your class): The Flipped Classroom Model
basically involves encouraging students to prepare for the lesson before
class. Thus, the class becomes a dynamic environment in which students
elaborate on what they have already studied.
o If visiting then how would you take out time for meetings?
xviii. Lesson planning: Approach is narrow downing:
TL SA R(reflection)SH(Homework]
xix. Expected Salary?

xx. Your views on online classes:

xxi. Did you get any professional development Training?


Yes these things are of equal importance besides your subject knowledge that's why i have been
very active in acquiring and applying different techniques in my classroom.

• As far as formal training is concerned on one hand, at bahria college karsaz where i taught 11
years we got indigenous training at BITT.

These were all certificate courses. They had a state-of-the art environment to train teachers
where the top instructors gave training in the areas like:

I did many courses there but main courses were:

-
1. Using table of specifications to construct tests
A table of specifications is a tool used by teachers to design a test or exam.

2. Preparing an effective lesson plan:

3. Communication; a ladder to success:

A Good Communication Skills makes ladder to success Short!

To make it great one should always think of below 5 questions to oneself while communicating:

• Am i talking relevant?
• Am i Clear in what i am communicating?
• Am i responding properly?
• Is my way comfortable for the other one to accept?
• Am i audible or legible to other one?

4. Holistic Personality development of students:


Holistic development essentially means the development of intellectual, mental, physical, emotional,
and social abilities in a child so that he or she is capable of facing the demands and challenges of
everyday life

1. Encourage Role Models. Students must choose a role model to follow. ...
2. Character Building. ...
3. Set Principles & Discipline. ...
4. Build Empathy. ...
5. Insist on Respect. ...
6. Volunteerism. ...
7. Actions Speak. ...
8. Avoid Labels.

https://www.usatestprep.com/blog/role-teachers-students-personality-
development/?__cf_chl_jschl_tk__=pmd_FC89FA4xi2pIostHcwacNZyxNRk.I24XG7BbPZtJUUA-
1630527923-0-gqNtZGzNAhCjcnBszQd9

5. moral development and education

oral development is the process throught which children develop proper attitudes and behaviors
toward other people in society, based on social and cultural norms, rules, and laws.

6. Effective teaching strategies:

The Top 10 Evidence Based Teaching Strategies will help you discover the science of what works.
• Clear Lesson Goals. ...
• Show & Tell. ...
• Questioning to Check for Understanding. ...
• Summarize New Learning In A Graphical Way. ...
• Plenty of Practice. ...
• Provide Your Students With Feedback. ...
• Be Flexible About How Long It Takes to Learn.

And on the other hand i was also the item's reviewer and subject panelist at akeb.

Akeb is actually extracted from cambridge syllabus to fufill local needs where we analyzed the cs
cambridge syllabus as
the standard syllabus and then to design and review it in such a way to fulfill local needs.

For example the use of a particular

programming language at grade 10 level, which is not required in cambridge.

And then as far as informal training is concerned,

i have subscribed many online channels to get online training and attend webinars.

xxii. Pure Cambridge training?


Nowadays internet is full of such training videos, coucourses. So already we have got so many material
to absorb that i think if you keep your eyes open to see what’s happening around, you can save your
time, money and energy.

I have been following since long the official CIE YouTube channel, Cambridge india, etc. to attend
webinars and online events like:

- Cambridge Schools (CIE’s official YouTube channel for teachers’ professional


development),
- Cambridge University Press Education,
- Cambridge India
- TED-Ed,
- “Teacher Development Webinars” (an online professional development platform to
connect people from around the world)

I attended / watched so many useful webinars like:

• What Really Matters in Bringing Computational Thinking in the Classroom.


• Adapting to teaching online – activities and techniques to engage primary & secondary learners
• Difference Between Computer Science and ICT
• Using Jamboard, Drawing, and Slides in your classroom

Besides that i myself keep reading cambridge's

recommended teachers' guides and lesson plans to constantly improve my way of teaching.
xxiii. Tell us about these things that you mentioned in your CV

Courses:

Transform Learning with Microsoft Teams:


hand i was also the item's reviewer and subject panelist at akeb.

Akeb is actually extracted from cambridge syllabus to fufill local needs where we analyzed the cs
cambridge syllabus as

the standard syllabus and then to design and review it in such a way to fulfill local needs.

For example the use of a particular

programming language at grade 10 level, which is not required in cambridge.


I got the membership from a reference by one of my colleagues.
xxiv. Are you aware of syllabus updates?

Yes it has been almost 50% updated.


Yes. Very well.

I have Sign-up for our syllabus updates


new topics:

1. addition of 8 bit numbers.

2. overflow in binary addition.

3. 2's compliment

4. Sound sample rate into bit

5.Some new sensors


Pearson also offers other courses like BTEC.

1. List down some frequently used phrases / sentences in phone calls /


interviews / demos:

i.Key Sentences to Introduce Yourself at a Job Interview in English


First impressions are always very important, and for a job interview it’s no different!
These are different sentences you can use to introduce yourself at a job interview in
English:
o Good morning/afternoon. [Only if it appears that the front person is modern]
o AOA. [Only if it appears the front person is conservative]
o [If they ask u how r u? then say] I m fine. And I want to thank you for taking me into
consideration for this position.
o Some other possible variations:
▪ My name is ______ and I want to thank you for this opportunity.
▪ Well, it’s a pleasure for me to be here.
▪ Good morning/afternoon. I’m _______ Hello! My name is _______ and I’m glad
you called me because I really want to work for this company.
▪ Hi! My name is ________ and I’m here because I think I have the profile you’re
looking for.

ii.Asking Someone to Repeat a Question


It’s natural and legitimate to ask for a question to be repeated.
o I’m sorry. Would you please repeat the question?
o Would you please say that again?
o Could you please repeat the question and speak a little bit harder?
o Sorry, I didn’t understand you.
o I’m sorry; I didn’t hear the last part. Can you repeat it, please?

iii.Emphasizing Your Strengths

o My (mention a set of skills relevant for the job) will allow me to do this easily.
o I’m very good at ________ and that’s why I think I’ll be able to handle this position. (Fill
the blank space with the one you consider is your best strength.)
o I follow exceptionally high standard.
o I can say my top 4 skills are: problem solving, planning and keeping proper
documentation and adaptation i.e. my experience has taught me how to adapt my work
to the needs of each one.
iv.Thanking the Interviewer at the End of the Interview in English
Don’t let the interviewer/s leave with a bittersweet taste and thank them before the
interview is over. These are some sentences for job interviews in English that can help you
thanking them:

o Thank you very much for your time. I’ll be waiting for your call!
o Before I leave I want to thank you for the opportunity. I hope we see each other again
soon!
o It was a pleasure meeting you and then again I want to thank you for having me here!
o You can expect nothing but proficiency and excellent results if you hire me.

https://www.english-at-home.com/business/vocabulary-and-phrases-for-making-
presentations/

v.Miscellaneous Important:
“Please feel free to interrupt me if you have questions.”

You see everything is connected.


“There will be time for questions at the end of the presentation.”
“I’d be grateful if you could ask your questions after the presentation.”

“This relates directly to the question I put to you before…”

“This leads me to my next point…”

“Let me put it this way.”

“Perhaps I can rephrase that.”

“This graph gives you a break down of…”

“This clearly shows …”

“That brings me to the end of my presentation.

“To summarise, I…”

Thank you for asking.

“That’s an interesting question.

“Thank you for listening – and now if there are any questions, I would be pleased
to answer them.”

“Does this answer your question?”


“Do you follow what I am saying?”
“I hope this explains the situation for you.”
“I hope this was what you wanted to hear

Introduction to Functions

The image you provided outlines a few terms related to programming blocks of code in the
context of pseudocode. I'll explain the differences between each:

1. Function/Procedure:
o Function: A block of code that performs a specific task and returns a value. It can
take inputs (parameters) and produces an output.
o Procedure: Similar to a function, but it does not return a value. It may perform
tasks like modifying global variables or performing an operation.
2. Subroutine/Library Routine:
o Subroutine: A reusable block of code that performs a specific task, and can be
called from different places in a program. It can be a procedure or function, and it
helps in avoiding code duplication.
o
Library Routine: A pre-written subroutine available in external libraries that can
be used in multiple programs without rewriting the code. It is stored in a library
and provides common functionality (e.g., mathematical operations or input/output
routines).
3. Module:
o A module is a self-contained block of code or a collection of related functions
and procedures. Modules can represent a larger organizational structure within
programs, often grouping related functionality or routines together to improve
code maintainability and clarity.

In summary:

• Function: Returns a value.


• Procedure: Does not return a value.
• Subroutine: Reusable, called from anywhere.
• Library Routine: Pre-defined subroutine in external libraries.
• Module: A group of related routines, functions, or procedures.

• Importance of the topic

• Need / benefits of Functions

• Definition of Function

• Syntax of Functions [with the help of an example]

• Types of functions
Importance of the topic:
Look at this program:

// Program to calculate square of a function


#include <stdio.h>
int calculateSquare(int x) // Function 2
{

int square = x * x;

return square;
}
int main() //Function 1
{
int num, result;
printf("Enter a number: ");
scanf("%d", &num);
result = calculateSquare(num);
printf("The square of %d is: %d\n", num,result);
By carefully return 0; at this program it is clear that this program is composed of two functions.
looking
}
Commented [AA3]: Take the example of a super store.
“Functions” is one of the most important topics to learn any programming language in general and C in Super store is also called as departmental store. Why?
particular. Because the store is divided into many departments like
grocery, medicines, electronics appliances and a main
administration department. Just like that we have many
Functions are so important that C is often called as a language which is based on functions. functions in a C program, one for each type of type of
specific work [make addition, subtraction, and
In other words we say that every C program is composed of functions. multiplication blocks]. And one 'main' function for
integrating and coordinating all other functions [now make
[But what does it mean?] a main block and write input numbers statements, function
calls to sum, sub and multiplication (and call each function
twice to emphasize reusability) and print statements].

But wait can you think of a store which is based on


just one department which is responsible for all
types of work. Well in that case the store is
actually a small shop which is run by just one
person because for a small shop there is no need
of separating work into many departments.
Similarly in C language if a program consists of
few lines of code, there is no need to make more
functions. In this case just one main function is
enough. That’s why when we start learning
programming in C language we just see programs
with one ‘main’ function only because in the
beginning we don’t make large scale programs.
But as we move forward and start to make large
programs, we need to divide our lines of code into
more functions.
Brief commentary on program:

Need of functions:
So functions fulfill our two needs or we can say that mainly there are two benefits of
functions:

Reduce the complexity by dividing a large program in different functions

Reusability by calling same function again and again.

Some other benefits are:

Definition of functions:
Make the process of debugging easier.

It allows a user to build a customized library of frequent user routine (by writing his own
header file).

Now the Definition of Function.

“A function is a named block of instructions that together perform a specific task”.

Syntax of functions:
Having known what is meant by a function and its benefits, now let’s discuss the syntax
of functions:

Example:
For this purpose let’s reconsider our example of making the program of doing different
arithmetic operations.

First of all we need a main function that will input the numbers and then call other
functions to actually perform the operations and display the result [now just start filling
the block that you made earlier for main function].

void main()
{

….

sum= addition(a,b);

printf(“the sum of the numbers is %d”, sum);

Now explanation of this code:

When writing the code for a function, first we need to mention the name (naam) of
function, followed by the work (kaam) of the function (which is enclosed in braces).

So let’s first discuss the naam:

In this case, as we know, the name is main, followed by a set of parenthesis which is the
identification symbol for every function. You can tell by identifying these parentheses
how many functions there are in your program. Here let me tell you these brackets are
not just for identification purpose only, in fact, we can provide any set of values in these
brackets as the input for that function. But right now just forget this thing we will discuss
it shortly.

And before the name of the function, we also mention the data type of the particular value
that this function will return). These could be int, float, char, double or void, where void
means nothing. In our case we know the purpose of this main function is to just input the
numbers and then call other functions to actually perform the operations and display the
result. It means it will return no particular value; it will just execute some controlling
statements. So here the return data type is void or nothing. Together, the return type,
name and set of parenthesis called as the function header, declaration or prototype.

Now let’s consider the kaam of the function:

All the work done by the function is enclosed in braces (Now just explain the statements
in this main function superficially but emphasize on function calling part)

Now let’s discuss another function ‘sum’. The purpose of this function is to receive the
numbers from main function, calculate the sum and return the sum to main function.

For this purpose we will write the code like this:

int sum(int x, int y)

{
….

return (addition)

Now explanation of this code:

Here, the function header is somewhat different from the main function because:

Unlike main, this function will return a particular value of type integer to the calling main
function, as a result of addition operation. That’s why we wrote int before its name.

Unlike main, it will also receive two numbers as input for which the sum is to be calculated
from main function. That’s why we wrote int x, int y in the parentheses. These are called
as parameters of the function.

Furthermore the body of this function also has a return statement because this function
is supposed to return an integer value. And this value will be placed at the location where
this function was called in main function.

Also keep in mind, if we are defining any other function after main function, we will have
to write function header before main function where all header files are written. This is
a language rule.

Types of functions:
Now considering the return type and the input parameters, we can classify functions in 4
types:

Return type Input parameters Example


No No void main()
No Yes void subtract(int a, int b)
Yes No int mul()
Yes Yes int sum(int a, int b)

i. Review of functions
It covers following topics of c language:
• All what you have done in Bahria lectures i.e. till chapter 9
• Pointers: Chapter 5 of let us c (start from p 174 of book from the topic “advanced featur
es of functions)
• Arrays: Chapter 8 of let us c
• File Input / Output: Chapter 12 of let us c
• FAQs in interviews about Programming fundamentals.

You might also like