Class 1 C

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 12

ITSE 1101 INTRODUTION TO PROGRAMING C

Shaik Mastan

Topics
 Programming languages  Types of Programming languages  Logic and problem solving  Problem solving phase  Writing algorithm  Draw flowchart  Implementation phase

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

 Examples:
FORTRAN JAVA COBOL C BASIC C ++ PASCAL

A text editor is used to write a program. Example: Notepad, Turbo editor, Norton editor

..

Types of Programming Languages


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 was very difficult to learn and understand by humans All the data and instructions had to be manually transcribed into Machine . Language (Binary Form) and all results had to be decoded from Machine Language to Human Readable form Coding and Decoding took a long time

Assembly Level Languages


 Support Mnemonic Codes ( ADD, SUB, MUL, DIV, JMP) 

abbreviations for standard repeated functions such as ADD for addition, SUB for subtraction, MUL for multiply, HLT for halting or stopping the program

 Thus, each assembly language code was restricted to a particular machine and required a Translator to convert it to a machine usable form.

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

WHY C
 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 distant cousin of C and share the same programming concept and syntax of C.
 Major parts of the Windows, Unix and Linux are still written in C.  Device drivers of new devices are always written in C.

Programming Task
 A programming task can be divided into two phases Problem solving phase : Produce an ordered sequence of steps that describe solution of problem. This sequence of steps is called an algorithm Implementation phase: Implement the program in some programming language

Steps in Problem Solving


 1. Produce a general algorithm (one can use pseudo code)  2. Refine the algorithm successively to get step by step detailed algorithm that is very close to a computer language.
Pseudo code is an artificial and informal language like structural English that helps 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

ALGORITHM
 An algorithm is a step by step procedure to solve a problem in a finite amount of time. The following criteria should satisfy the algorithm: Input, output, effective ness, infiniteness.  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

Detailed Algorithm
Step 1: Input S1, S2, S3 Step 2: Average = (S1+S2+S3)/3 Step 3: if (Average < 50) then Print FAIL else Print PASS endif

EXAMPLE
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

You might also like