Documente Academic
Documente Profesional
Documente Cultură
UNIT - 1
Complete
Details
Module
No. : 1 (1/4)
Chapter
No. :
Unit No. : 1 (1/20)
Video Lecture Duration : 96 Minutes
CONTENTS
7
2 1 - HELLO, C!
10 GUIDELINES
For Mastering Programming Skills
Understand the underlying spirit of the following guidelines and strictly adhere to them-
2
1 - HELLO, C! 3
If you acquire such a confidence that you can explain the concept to others, it is the ultimate test. If
possible, you may try it.
8. List out all the doubts and get answers for them
A doubt is an obstruction in our studies. If a student gets doubts frequently, obviously he/she will
lose interest in the subject. That is why, we developed this course as 100% doubt free. Inspite of it,
if you get any doubt, list it out and find the answer at the earliest. You may feel free to mail us for
any clarifications.
All these guidelines enable you to shift from the college-oriented style of study to career-oriented
style of study. If you are a true aspirant of a bright Software career, strictly adhering to these
guidelines is a must.
3
4 1 - HELLO, C!
You must remember that this is a true IT Placement Training program, but not one of your
college-training programs. The basic objective of this training program is to enrich your
Employability criteria, which is expected by the IT industry and Transform you as an
Industry-ready programmer.
Employability means Knowledge, Skills and Abilities (KSA) to acquire a suitable
employment and to maintain the same. You must know the clear meaning of the
Employability, before undergoing the training to acquire it. Illustratively, Knowledge is
like knowing the recipe of a dish, Skill represents the competence to prepare the dish and
Ability represents the competence to prepare the same dish with different tastes.
In college-oriented studies, the main focus of most of the students is on acquiring only
knowledge required for getting marks. In this approach, there is a little room for acquiring
skills. In order to accomplish abilities, acquiring the corresponding skills is a must.
In this scenario, for enriching the employability of students for transforming them into IT
Industry-ready programmers, we are classifying the IT career aspirants into two virtual
groups. They are:
1. Students (College-goers)
2. Graduates
Even though these two groups undergo the same placement training, their study-plans
should be different. Obviously as college-going students are busy with their college
schedules, I recommend a suitable plan for them. If they start this placement training
preparation just at the beginning of any semester holidays, they may concentrate exclusively
on this course for one month and can finish at least a minimum of 30% of the course. Above
that, they are well tuned up with the methodology of the training. And during the semester
period, if they continue their focus on this training, subject to the available time, they can
finish at least 45% of the training. They may finish remaining 25% of the course in the
semester vacation. If they are interested, they may prepare for the International Certification
exam namely OCAJP (Oracle Certified Associate Java Programmer). With this training,
they can well compete in the campus recruitment or any other and succeed.
For Graduates (of IT or non-IT), we have prescribed a 120-day careerSURE Finishing program
to acquire employability and evolve as the IT Industry-ready programmers. You may refer
the complete details of this program on our website.
4
1 - HELLO, C! 5
1. HELLO, C!
Congratulations to all of you for stepping into the programming world. In fact, C is the
golden threshold for entering into the programming world, because C was evolved as the
first general-purpose language and it provided building blocks for the many advanced
languages such as C++, Java, C#, Python etc. In my view, illustratively the command over
C acts as the foundation and the ground floor of multi-storied (programming) building. As
you are aware, once laying foundation and the construction of ground floor are finished, the
super stories can be built with lot of speed and ease.
Not only teaching programming languages, but also I want to teach many techniques, which
are useful for mastering them with ease and time-saving, contextually. In fact, these are
management techniques, which are aptly modified to suit for our programming studies.
Understand the real spirit of these techniques and implement them properly.
The first one is the Quantitative Technique. Before taking up any big task, first quantify the
entire job and devise your implementation plan, subject to all your strengths and limitations.
Let us apply this first technique to our C training.
Quantification Report
No. of Chapters : 20
No. of Projects : 50
Keeping this report in view, you study for one week and appraise your Weekly productivity.
Based on that, you can prepare the time plan, for the entire C training. And this helps you
not only for maintaining a study discipline but also for completing your program according
to your pre-defined time-plan.
5
6 1 - HELLO, C!
At a Glance....
At the Outset, I want to explain the programming basics. This knowledge helps
you a lot to understand the concepts, which we will discuss in the next units,
smoothly. And also this knowledge prevents the probable doubts arise in you
study as well as in applications.
A doubt is an obstruction in our study. If several doubts are accumulated and
remained uncleared, the student loses interest in the subject. "Prevention is
better than Cure". As a preventive measure, I am introducing a set of relevant
programming basics in this first Unit. That's the reason, you must study these
basics thoroughly, before moving to the next unit.
You must remember that the knowledge of the relevant basics helps you to
understand and own a concept, whereas a concept provides the blueprint for the
corresponding applications. By ignoring concepts, if you take up applications,
you never be comfortable in developing applications. Your style of working will
be always similar to "Blind Man's Walk".
Through this Workshop, you will experience a Weekend Wonder. Don't try any
shortcuts in this study. Always Remember:
6
1 - HELLO, C! 7
1.1 UNDERSTANDING COMPUTER PROGRAM
A Computer performs all our Computational tasks, strictly according to our instructions. We
make a set of computer instructions, as a bundle, and feed it to a computer. Such a set (bundle)
of instructions is called a Computer Program.
Computer Program-Definition
A Computer program is:
i. a set of computer instructions,
ii. which manipulates a set of given data,
iii. to achieve a pre-defined task and
iv. which is executed on a computer.
Understand this definition through the following example:
a) Task of the program : To Prepare and Print a Marks Report of a Student
b) Set of Instructions i. Start the Program
ii. Read the Marks of 5 papers from keyboard
iii. Add the Marks of 5 papers (Finding the Total Marks)
iv. Calculate the Average Marks
v. Display the Marks Report
vi. Stop the Program
c) Set of Data: Marks in 5 Papers
With this example, you can understand the meaning and purpose of a computer program.
The set of instructions (6 nos.) acts upon a set of data (i.e.: Marks in 5 papers), to achieve the
pre-defined task (i.e. preparing and displaying marks report). This program is executed on a
computer, as it is a computer program. As a computer program is like a human programme,
similar names (i.e. Program and Programme) are given to these terms. Therefore, if you
understand every concept in the programming from the real life angle, you can understand
the concepts and own them easily. Since the concepts provide blueprints for the corresponding
applications, conceptual understanding enables you to master programming and achieve the
corresponding skills.
Note that concepts act like blueprints for the programs. So, by understanding concepts well,
you can write programs well. By writing programs well, you can own the corresponding
concepts. Therefore, understand that concepts and the corresponding programs are
complementary sources to master programming.
There are nine steps totally. It means, in order to achieve the task of the program(me), your
assistant implemented 9 steps sequentially. Notice that a computer program is almost similar,
and implemented the algorithm (series of steps) to perform the tasks, say Printing Marks Report.
By comparing a human programme with a computer program, you can find the following
differences:
i. Medium
Your medium of language and your assistant’s medium are same. That’s way, your assistant
could understand your instruction. Since a computers can’t understand a human language,
various computer languages were created, in order to enable us to interact with computers.
Therefore, we should learn a computer language, such as C, C++, or Java, in order to instruct
a computer or for writing computer programs. As you know, a program is nothing but a set of
computer instructions.
ii. Brain
Even though you have given a simple and single-line instruction orally, or sometimes through
your behavior to your assistant, he can analyze it, develop algorithm (sequence of steps),
implement them sequentially, perform the job, and ultimately achieve the task of the programme.
He can do all this, because of his BRAIN and its analytical power. Note that his Brain itself can
understand the instructions, develop the algorithm, convert all steps in the algorithm as the set
of instructions (like a program or software), and send them to the corresponding limbs (like
hardware), and got the programme performed.
As Computer is a brainless machine. But it has a unique capability to implement programs (set
of Instructions) accurately. So, we have to develop algorithm, convert it into a program (software),
and give it to a computer, to a implement the program.
1 - HELLO, C! 9
iii. Speed
An ordinary computer can perform its jobs millions of times faster than a human being.
Whatever amount of computational jobs, a person can perform within a year, that amount of
job can be performed by an ordinary computer, within minutes, without any mistakes.
iv. Mistakes
If your program contains any logical mistakes, the computer can neither identify them nor
rectify them, and implements the program with those shortcomings only, because it has no
discretionary power. Whereas your assistant may rectify your mistakes if any, as he has brain,
as well as discretionary power. But if you write your computer program without any
shortcomings, computer never commits any mistakes, and it implements it accurately, whereas
your assistant may commit mistakes, because he is a human, obviously ‘err is human’.
Understanding of the real spirit of this concept enlightens you as to what extent you can
depend on the computer, subjected to its limitations.
1.4 FUNCTION-ORIENTED PROGRAMMING (FOP) APPROACH
C is a Function-Oriented Programming (FOP) language. That means, every C program is
developed as the composition of a set of functions. Every C function is represented with an
identifier and a set of parenthesis. E.g.: main( ), sqrt( ), clrscr( ). Normally a function's name
(identifier) represents, what that function does. For example, the main( ) function is the 'Main',
means, acts like the 'Manager' of a program. The sqrt( ) function calculates the square root of the
given value to it, as an argument. E.g; sqrt(100) is 10.
The simplest and valid C Program is main () { }
This is the smallest C program. No doubt, this is a valid C program, and its task is
doing nothing. “Do Nothing” is a valid task for a C Program. But, in real life, 'Do – nothing’ is not
at all considered as a valid activity In certain situations, a program should be in “Do Nothing”
state for some time. That means, it should work, without doing anything.
Understand that every function in a C program, is like a specialist in our real life, such as a
carpenter, an electrician, a mechanic, a painter etc. The C functions (specialists) perform jobs,
such as Receiving data from the keyboard (called as Reading), Displaying data on the monitor
screen (called as Writing), Clearing data written on the monitor output screen (acting as a
black board Duster), Calculating the square root of a given number etc., For any function, beside
its name, a pair of parenthesis must be written. E.g: main( ), scanf( ), printf( ), clrscr( ), sqrt( ).
main( ) Function:
The main( ) function acts like the manager of a program. Without a manager, there is no office.
Similarly, without main( ), function, there is no C program. So, the main( ) function is a
compulsory function in a C program. This means, we can’t write a C program without a
main( ) function. The execution of a C program starts from the main( ) function only, as this is
the entry point of a program. These are only the specialities of the main( ) function. Except
this, the main( ) function is also like any other C function, by all means.
The C's Function-oriented model is just like real life model, which we adopt in our daily life.
You are the Manager of your house. If you want to get your house cleaned, you call a specialist
named Cleaner. If you want to get your house painted, you call two specialists: Painter and
Cleaner. If you want to get your house shifted, you call three types of specialists: Packers,
Lifters and Movers. If you have to get a house constructed, you call many specialists such as,
Architect, Engineer, Manson, Transporter, Labourers,Carpenter, Electrician, Plumber, etc. As
the main( ) is the manager of a C program, it acts exactly like you, as explained above. More
specifically, depending on the task of the program, the main( ) function calls various other
functions and each such function performs its subtask. Ultimately the main( )'s task is
performed, by collective contribution of all such function.
10 1 - HELLO, C!
Note that from the day-one, you can't write your C programs in the Function-oriented model,
as shown above. After learning many concepts and writing all types of statements, you will
be able to write your programs in the Function-oriented model.
Examine one more example of the FOP model. If you have to write a program to print the
Cash Bill of a Hotel, it is to be written with the following list of functions.
Note that, these examples are given, just for the understanding FOP Model. At this stage,
don't think about the complexity involved in writing the same program. Just within a few
days, you will be able to write programs exactly in the Function-Oriented Model. Believe me.
So far, we have learnt the basic concepts of a computer program and Function-oriented
Programming (FOP) approach. Now, let us start writing our first C program.