class-1-c

12
ITSE 1101 INTRODUTION TO PROGRAMING C Shaik Mastan

Upload: gouse5815

Post on 06-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CLASS-1-C

8/3/2019 CLASS-1-C

http://slidepdf.com/reader/full/class-1-c 1/12

ITSE 1101

INTRODUTION TO PROGRAMING C

Shaik Mastan

Page 2: CLASS-1-C

8/3/2019 CLASS-1-C

http://slidepdf.com/reader/full/class-1-c 2/12

Programming languages

Types of Programming languages Logic and problem solving

Problem solving phase

Writing algorithm

Draw flowchart

Implementation phase

Topics

Page 3: CLASS-1-C

8/3/2019 CLASS-1-C

http://slidepdf.com/reader/full/class-1-c 3/12

A program is set of instructions used to build up a software program.

Examples:FORTRAN COBOL BASIC PASCAL

JAVA C C ++

Atext editor is used to write a program.

Example: Notepad, Turbo editor, Norton editor ..

Programming Language

Page 4: CLASS-1-C

8/3/2019 CLASS-1-C

http://slidepdf.com/reader/full/class-1-c 4/12

Machine Level Language Support the numbers 0 & 1

Advantages:· Directly understandable by the computer 

· Processing and results were extremely fast Disadvantages:

· Being represented in Binary form, the codes were wasvery difficult to learn and understand by humans

· All the data and instructions had to be manuallytranscribed into Machine

. Language (Binary Form) and all results had to be decodedfrom Machine Language to Human Readable form· Coding and Decoding took a long time

Types of Programming Languages

Page 5: CLASS-1-C

8/3/2019 CLASS-1-C

http://slidepdf.com/reader/full/class-1-c 5/12

Assembly Level Languages Support Mnemonic Codes ( ADD, SUB, MUL, DIV, JMP)

abbreviations for standard repeated functionssuch as ADD for addition, SUB for subtraction,MUL for multiply, HLT for halting or stopping theprogram

Thus, each assembly language code was restricted toa particular machine and required a Translator toconvert i t to a machine usable form.

Page 6: CLASS-1-C

8/3/2019 CLASS-1-C

http://slidepdf.com/reader/full/class-1-c 6/12

High Level Languages Support English language. It has specific structure. Needs compilers or interpreters to be understood by the

computer  Advantages:

· Uniformity achieved:overrides the deficiency of machine dependent code· Use of English with proper syntax made it easier to write

programs· Programs written in High Level Languages are much

shorter, versatile and faster to work with and debug

Page 7: CLASS-1-C

8/3/2019 CLASS-1-C

http://slidepdf.com/reader/full/class-1-c 7/12

C is simple it is one of the most powerful languages

It is language on which C++ is based on, hence C# also

derive its origin from the C. Java is also a distantcousin of C and share the same programming conceptand syntax of C.

Major parts of the Windows, Unix and Linux are still

written in C. Device drivers of new devices are always written i n C.

WHYC

Page 8: CLASS-1-C

8/3/2019 CLASS-1-C

http://slidepdf.com/reader/full/class-1-c 8/12

A programming task can be divided into two phases

· Problem solving phase :

Produce an ordered sequence of steps thatdescribe solution of problem.

This sequence of steps is called an algorithm

· Implementation phase:Implement the program in some programming

language

Programming Task

Page 9: CLASS-1-C

8/3/2019 CLASS-1-C

http://slidepdf.com/reader/full/class-1-c 9/12

1. Produce a general algorithm (one can use pseudo code)

2. Refine the algorithm successively to get step by stepdetailed algorithm that is very close to a computer language.

Pseudo code is an artificial and informal language like structural English thathelps programmers develop algorithms.

Example:

Input a set of 3 marks

Calculate their average by summing and dividing by 3

if average is below 50

Print FAIL

else

Print PASS

Steps in Problem Solving

Page 10: CLASS-1-C

8/3/2019 CLASS-1-C

http://slidepdf.com/reader/full/class-1-c 10/12

An algorithm is a step by step procedure to solve a problem in afinite amount of time.

The following criteria should satisfy the algorithm:

Input, output, effective ness, infiniteness.

Example:Input a set of 3 marksCalculate their average by summing and dividing by 3

if average is below 50

Print FAILelse

Print PASS

ALGORITHM

Page 11: CLASS-1-C

8/3/2019 CLASS-1-C

http://slidepdf.com/reader/full/class-1-c 11/12

Detailed Algorithm

Step 1: Input S1, S2, S3

Step 2: Average = (S1+S2+S3)/3

Step 3: if (Average < 50) then

Print FAIL

elsePrint PASS

endif

Page 12: CLASS-1-C

8/3/2019 CLASS-1-C

http://slidepdf.com/reader/full/class-1-c 12/12

1. Algorithm for addition of two numbers

Step 1: Read Two numbers N1, N2

Step 2: Find Sum

Sum = N1 + N2

Step 3: Print sum

EXAMPLE